6

I have read the question from Sending images to google cloud storage using google app engine.

However, the codes in the answer that the file will upload to Blobstore first, so the file can not be exceeded 32MB.

How can I upload the large file to Google Cloud Storage directly?

I have checked the official document Upload Objects, but I still don't know how to write a form to post a large file.

Community
  • 1
  • 1
Jerry
  • 63
  • 1
  • 3
  • there is no 32mb filesize limit on the blobstore. it is a limit on how many mb you can read in one api call. `the maximum size of Blobstore data that can be READ by the application with one API call is 32 megabytes.` – aschmid00 Jul 06 '12 at 15:19
  • @aschmid00: Thanks for your comment. However, I still don't know how to upload file to Blobstore without calling API... – Jerry Jul 06 '12 at 15:23
  • its not the api call to upload it that limits you but the api call to read the blob. you should read the docs first https://developers.google.com/appengine/docs/python/blobstore/overview#Uploading_a_Blob you need to generate the upload url when the form is rendered or get it with an ajax call on a later moment – aschmid00 Jul 06 '12 at 15:48
  • @aschmid00: Thanks for your fast reply. I do read the docs you mention, and have used in my web site. But I still want to know how to use a form to upload a large file to Cloud Storage directly and read it later. – Jerry Jul 06 '12 at 16:00
  • this should help you out https://developers.google.com/appengine/docs/python/googlestorage/overview – aschmid00 Jul 06 '12 at 16:03
  • @aschmid00: I have read that. Writing a txt file to Cloud Storage is no problem, but I know nothing about how to upload a image or large file to Cloud Storage directly... – Jerry Jul 06 '12 at 16:55
  • @Jerry, unfortunately nobody can help you (and me as well). Nobody post a sample working code. I did it with Java just attaching pieces of code together, taken from different websites, but i have a problem with file larger than 32Mb even if they tell that Google Cloud Storage has "no limits". – Aerox Apr 17 '14 at 10:27

2 Answers2

13

easy since 1.7.0

upload_url = blobstore.create_upload_url('/upload_handler', gs_bucket_name='my_bucket')

Will upload straight to Google Storage and return you blob keys that point to the uploads in Cloud Storage.

Stuart Langley
  • 7,044
  • 1
  • 20
  • 20
  • wow, it works! Thank you! Is it possible to use the upload_filename to setup the filename in bucket? – Jerry Jul 08 '12 at 05:16
  • not currently - we use a "random" filename so we have the same semantic as uploads to blobstore, where you can upload the same file time after time and get a new blob generated. – Stuart Langley Jul 08 '12 at 10:26
  • @StuartLangley and how to retrieve this filename? Using get_uploads() in BlobstoreUploadHandler just returns a weird key. – Julian Go Nov 06 '12 at 12:34
  • This issue looks like it was fixed as of Mar 11, 2013 https://code.google.com/p/googleappengine/wiki/SdkForJavaReleaseNotes – Doruk Jul 07 '13 at 17:36
2

upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='mybucketname')

does get the upload with the blob key to the cloud storage but it still puts the uploaded file in the blobstore as well.

Jay
  • 496
  • 1
  • 4
  • 11