python - GAE BlobstoreUploadHandler doesn't recognize files -


when send request client this:

with open(config.datafile, "rb") f:   r = requests.post(config.endpoint, files={"file": f})   print r.text 

to gae app this:

class fileuploadhandler(blobstore_handlers.blobstoreuploadhandler):    def post(self):     self.response.out.write(self.get_uploads()) 

i expect this:

{   "file": "line 1\nline 2\nline 3\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\n" }, 

but instead request putting file data in data if change app this:

class fileuploadhandler(blobstore_handlers.blobstoreuploadhandler):    def post(self):     self.response.out.write(self.request.get("file")) 

i response body like:

line 1 line 2 line 3 ... 

this seems contrary documentation. can explain why please?

i suspect sending file url mapped fileuploadhandler. not right thing do.

you need upload file url returned blobstore.create_upload_url.

even cannot access file through request. have use blobreader access it.

here relevant docs:

upload blobstore: https://cloud.google.com/appengine/docs/python/blobstore/#python_uploading_a_blob

read blobstore: https://cloud.google.com/appengine/docs/python/blobstore/blobreaderclass


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -