将Blob批量上传到Google App Engine [英] Batch upload of Blobs to Google App Engine

查看:181
本文介绍了将Blob批量上传到Google App Engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将网站迁移到Google App Engine。以前,所有的图像和静态资源(100 MB的东西)只是部署的一部分。



现在,很明显,我应该在GAE中使用Blob存储(否则更新应用程序将是巨大的痛苦!)。

我需要将这些镜像从我的磁盘上批量上传到GAE,并怀疑我需要某种脚本来执行此操作。任何想法或建议的最佳方法?

解决方案

目前的bulkloader不支持这一点,但可以自己写一个。这个过程如下所示:


  1. 编写一个处理上传的blob的处理程序,描述这里。让它将新创建的blob的关键字写入数据存储区,或者通过重定向将其返回给上传器,或者任何最适合您的应用程序的返回。

  2. 编写上传脚本。您可以使用 remote_api 调用blobstore create_upload_url 函数,然后使用urllib来上传文件。请确保以多部分形式对文件进行编码,以便blobstore正确识别它。
  3. 只有修改后的文件,所以你可以存储大量的静态内容,他们只会被上传,如果他们已经改变。但是,这可能不会帮助你,因为应用程序的大小限制在300MB以内。


    I'm currently migrating a site to Google App Engine. Previously, all the images and static resources (100s of MBs of the stuff) was just part of the deployment.

    Now, it's clear, I should use Blob Storage for this in GAE (otherwise updating the app will be mega-painful!).

    I need to batch upload these images from my disk to GAE and suspect I need some kind of script to do this. Any ideas or suggestions of the best approach?

    解决方案

    The current bulkloader doesn't support this, but it's possible to write one yourself. The process goes something like this:

    1. Write a handler that handles uploaded blobs, described here. Have it write the key of the newly created blob to the datastore, or return it via a redirect to the uploader, or whatever is most suitable for your app.
    2. Write an upload script. You can use remote_api to call the blobstore create_upload_url function, then use urllib to upload the file. Be sure to encode the file in a multipart form for the blobstore to recognize it correctly.

    As a side note, uploading an app uploads only the modified files, so you can store large amounts of static content, and they'll only be uploaded if they've changed. This probably doesn't help you here, though, as apps are limited to 300mb in size.

    这篇关于将Blob批量上传到Google App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆