将图像迁移到 google App Engine 数据存储或 blobstore

migrating images to google app engine datastore or blobstore

我有 属性 模型,包含一个字段 image_url。

class Property(ndb.Model):
    date_created=data.UTCDateTimeProperty(auto_now_add=True)
    # some other fields here
    image_url = ndb.StringProperty(indexed=False)

和图像模型,

class Image(ndb.Model):
    property = ndb.KeyProperty()
    file = ndb.KeyProperty(indexed=False)
    # some other fields
    image_url = ndb.StringProperty(indexed=False)

现在我的本地计算机中每个 属性 有 'n' 个图像。每个图像的名称映射到 csv 文件中相应的 属性 id。我想将所有这些图像从我的本地计算机批量上传到 google 应用引擎数据存储或 blobstore。 我尝试 google 起来,但感觉被卡住了,非常感谢任何帮助或参考。

Google Cloud Storage 可能是您更好的选择:

  • 你得到了一个很好的程序来使用它,gsutil,它可以让你从控制台轻松上传,这样你就可以编写自己的脚本:)

  • 您可以保留已有的文件名,并设置您自己的目录结构,以便它对您的应用程序更有意义。如果数据是静态的,那么您甚至可能不需要支持模型。

示例,来自上面的链接,关于您最终如何上传图片:

gsutil cp *.jpg gs://images

The cp command behaves much like the Unix cp command with the recursion (-R) option, allowing you to copy whole directories or just the contents of directories. gsutil also supports wildcards, which makes it easy for you to copy or move batches of files.