Need help processing upload form with Google App Engine Blobstore

后端 未结 1 353
别跟我提以往
别跟我提以往 2021-01-21 07:54

I\'m trying to learn the blobstore API... and I\'m able to successfully upload files and get them back, but I\'m not having any luck trying to combine an upload form with a regu

相关标签:
1条回答
  • 2021-01-21 08:17

    The problem is that your posted form data is lost when you redirect the request to "/save/%s", which is normal.

    Instead of redirecting, you should put your code inside UploadHandler, like this (untested code) :

    class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
        def post(self):
            try:
                upload_files = self.get_uploads('file')
                blob_info = upload_files[0]
    
                newFile = StoredFiles()
                newFile.nickname = self.request.get('nickname')
                newFile.blobkey = blob_info.key()
                newFile.put()
    
                self.redirect('/')
            except:
                self.redirect('/upload_failure.html')
    

    See this page from the docs for a similar example : http://code.google.com/appengine/docs/python/tools/webapp/blobstorehandlers.html#BlobstoreUploadHandler

    0 讨论(0)
提交回复
热议问题