1

I am wondering how to fix this error in google app engine using flask. I understand that a file cannot exceed 32 MB. I am uploading videos and trying to store them in google cloud storage, I need to handle large videos. I have heard that using blobstore api may help but have not found much documentation on this and how I can implement it in this code.

<form id = "form2" action="{{ url_for('createPost') }}" method="POST" enctype="multipart/form-data">
<div class="form-group">
    <label for="files4">Video:</label>
    <input type="file" id="files4" name='files4'>
 </div>
</form>


def createPost():
    if request.method == 'POST':
    s = db.session()
    try:
        files4 = request.files.getlist('files4')
        print(files4)
    except Exception as e:
        print("[Upload] Got exception: %s" % str(e))
    return redirect(url_for('projects'))
Akhil Yeleswar
  • 87
  • 1
  • 1
  • 12
  • Possible duplicate of [can we count the upload filesize before uploading in python-flask](https://stackoverflow.com/questions/14000569/can-we-count-the-upload-filesize-before-uploading-in-python-flask) – Fine Mar 18 '19 at 12:33

1 Answers1

2

Here are 2 methods by which you can do this via blobstore:

1 - create_upload_url

https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.ext.blobstore.blobstore#google.appengine.ext.blobstore.blobstore.create_upload_url

and here is an example

https://www.programcreek.com/python/example/103205/google.appengine.ext.blobstore.create_upload_url

2 - BlobstoreUploadHandler however this requires you to use webapp2 instead of flask, although you could setup a webapp2 micro-service just for this endpoint

https://cloud.google.com/appengine/docs/standard/python/tools/webapp/blobstorehandlers#BlobstoreUploadHandler

If neither of these methods work, then you'd need to setup an app engine flex micro-service, so that you can edit the nginx conf to all files larger that 32 MB

Alex
  • 5,141
  • 12
  • 26