For an application, I have upload files on both blobstore and cloud storage.
I am doing that by generating upload links by this:
upload_url = blobstore.create_upload_url('/upload', gs_bucket_name=app_identity.get_default_gcs_bucket_name())
Files are saved on both blobstore and cloud storage, and I can perform GQL queries to retrieve any files I want from blobstore. However, I am unable to find a way to get the filename in cloud storage.
When files are uploaded in cloud storage, it is assigned a long filename automatically.
I found a command, but I am not sure how to use this: https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.ext.blobstore.blobstore#google.appengine.ext.blobstore.blobstore.BlobInfo
When I tried:
cloud_store = []
for upload in uploads:
gcs_link = blobstore.BlobInfo(db.get(upload)).gs_object_name
cloud_store.append(gcs_link)
Here uploads
stores result of a GQL query performed on a kind that has blobstore.BlobReferenceProperty()
property.
I get this error:
BadArgumentError: Expected an instance or iterable of (<type 'basestring'>, <class 'google.appengine.api.datastore.Entity'>, <class 'google.appengine.api.datastore_types.Key'>); received <models.PhotoAlbum object at 0x00000000054CD7B8> (a PhotoAlbum).
When I tried:
cloud_store = []
for upload in uploads:
gcs_link = blobstore.BlobInfo(upload.key()).gs_object_name
cloud_store.append(gcs_link)
I get this error:
TypeError: Must provide Entity or BlobKey