I'm programatically uploading image files and want to set the filename. When I upload a file via POST, the filename property is set automatically. However when using the method below, the filename is not getting set.
image = urllib2.urlopen(url)
file_name = files.blobstore.create(mime_type='image/png')
with files.open(file_name, 'a') as f:
f.write(image.read())
files.finalize(file_name)
image_blob_key = files.blobstore.get_blob_key(file_name)
Parse the filename from the url (see related question here). Then you can set it by adding an additional parameter to your files.blobstore.create call:
file_name = files.blobstore.create(mime_type='image/png',_blobinfo_uploaded_filename=file_name_from_url)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With