Hi, BlobstoreUploadHandler.get_uploads(field=fieldname) is not working at all

44 views
Skip to first unread message

Sunanda Samaddar

unread,
Jan 8, 2020, 9:50:10 AM1/8/20
to Google App Engine
I hope this is the right place for this question. Can somebody please help me with this basic Blobstore file upload issue?

snapshot from main.py
```
class HomeHandler(BaseHandler):
def get(self):
upload_url = blobstore.create_upload_url('/upload_file', gs_bucket_name=BUCKET_NAME)
context['upload_url'] = upload_url
self.render_response('home.html', **context)


class UploadHandler(BlobstoreUploadHandler):
def post(self):
"""Upload JSON and CSV files to CS bucket."""
file_infos = self.get_file_infos('file_upload') # returns [] everytime
uploads = self.get_uploads('file_upload') # returns [] everytime
print(file_infos, uploads)

self.redirect('/'.join(['/?', urllib.urlencode({'file_upload': uploads[0] or uploads[1]})]))


app = webapp2.WSGIApplication([('/', HomeHandler),
('/upload_file', UploadHandler)], debug=True)
```

Pierre-Yves Blain

unread,
Jan 8, 2020, 1:22:54 PM1/8/20
to Google App Engine
1- Please provide additional information about the context of your issue, and what you are trying to achieve
2- Please provide the full details of the error returned
3- Please provide the documentation that was followed to implement this "main.py" file

Sunanda Samaddar

unread,
Jan 9, 2020, 9:46:00 AM1/9/20
to Google App Engine
There was a missing closing tag in the template inside the upload <form> tag like
<form ... enctype="mutipart/form-data"
, hence get_uploads('file_upload') was put in a bad situation to work as expected. After closing the tag, it is working.  

Sunanda Samaddar

unread,
Jan 12, 2020, 1:26:22 PM1/12/20
to Google App Engine
Sorry, to be exact the problem code was like `<form ... enctype="mutipart/form-data>`.
Reply all
Reply to author
Forward
0 new messages