将图像迁移到google app engine数据存储或blob

2024-04-26 02:16:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个属性模型,包含一个字段图像和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。我想批量上传所有这些图片从我的本地机器到谷歌应用引擎数据存储或blobstore。 我试图谷歌了,但觉得我卡住了,任何帮助或参考将不胜感激。你知道吗


Tags: 模型图像imagefalseurlfieldsmodel属性
1条回答
网友
1楼 · 发布于 2024-04-26 02:16:53

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.

相关问题 更多 >