简体   繁体   中英

migrating images to google app engine datastore or blobstore

I have property model, containing a field 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. Name of each image is mapped to corresponding property id in csv file. I want to bulk upload all these images from my local machine to google app engine datastore or blobstore. I tried to google up but feel like I am stuck, any help or reference would be highly appreciated.

Google Cloud Storage might be a better option for you:

  • 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 :)

  • 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. gsutil also supports wildcards, which makes it easy for you to copy or move batches of files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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