Uploading Files in webapp2/GAE

前端 未结 2 670
予麋鹿
予麋鹿 2020-12-19 22:37

I need to upload and process a CSV file from a form in a Google App Engine application based on Webapp2 (Python) I understand I could use blobstore to temporary store the fi

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 22:55

    The content of uploaded files is in self.request.POST in your handler, so you can get that content (assuming e.g the field for the uploaded file is named 'foo') with e.g

    content = self.request.POST.multi['foo'].file.read()
    

    So now you have the content as a string -- process it as you wish. This does of course assume the thing will fit in memory (no multi-megabyte uploads!-)...

提交回复
热议问题