我陷入困境..我使用tipfy作为框架在scribd商店和blobstore上传文件.我的webform with action不是由blobstore.create_upload_url创建的(我只是使用url_for('myhandler')).我这样做是因为如果我使用blobstore处理程序解析了POST响应,我就不能使用普通的python-scribd api将文件上传到scribd store.现在我有工作的scribd saver:
class UploadScribdHandler(RequestHandler, BlobstoreUploadMixin):
def post(self):
uploaded_file = self.request.files.get('upload_file')
fname = uploaded_file.filename.strip()
try:
self.post_to_scribd(uploaded_file, fname)
except Exception, e:
# ... get the exception message and do something with it
msg = e.message
# ...
# reset the stream to zero (beginning) so the file can be read again
uploaded_file.seek(0)
#removed try-except to see debug info in browser window
# Create the file
file_name = files.blobstore.create(_blobinfo_uploaded_filename=fname)
# Open the file and write to it
with files.open(file_name, …Run Code Online (Sandbox Code Playgroud)