简体   繁体   English

将图片迁移到Google App Engine数据存储区或Blobstore

[英]migrating images to google app engine datastore or blobstore

I have property model, containing a field image_url. 我有一个属性模型,其中包含一个字段image_url。

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

and image model, 和图像模型

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

Now I have 'n' number of images for each property in my local machine. 现在,我的本地计算机中每个属性的图像数量为n。 Name of each image is mapped to corresponding property id in csv file. 每个图像的名称都映射到csv文件中的相应属性ID。 I want to bulk upload all these images from my local machine to google app engine datastore or blobstore. 我想将所有这些图像从本地计算机批量上传到Google App Engine数据存储区或Blobstore。 I tried to google up but feel like I am stuck, any help or reference would be highly appreciated. 我尝试使用Google进行搜索,但是觉得自己被困住了,我们将不胜感激任何帮助或参考。

Google Cloud Storage might be a better option for you: Google云存储可能是您更好的选择:

  • You get a nice program to work with it, gsutil , that will let you upload easily from the console, so you can write your own scripts :) 您将获得一个不错的程序gsutil ,它可以让您轻松地从控制台上传,因此您可以编写自己的脚本:)

  • You can keep the filenames you already have, and setup your own directory structure so that it makes more sense for your app. 您可以保留已有的文件名,并设置自己的目录结构,以使其对您的应用程序更有意义。 If data is static then you might not even need support models. 如果数据是静态的,那么您甚至可能不需要支持模型。

Example, from the links above, on how you'd end up uploading your images: 通过上面的链接,示例了如何最终上传图像:

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. cp命令的行为与带有递归(-R)选项的Unix cp命令非常相似,它允许您复制整个目录或仅复制目录的内容。 gsutil also supports wildcards, which makes it easy for you to copy or move batches of files. gsutil还支持通配符,这使您可以轻松复制或移动一批文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM