【发布时间】:2014-10-07 16:30:11
【问题描述】:
我正在尝试从我的应用引擎应用上传到云存储,但它一直在上传文件的名称而不是其内容。
html 很简单:
<form id="uploadbanner" enctype="multipart/form-data" action="/upload">
<input id="fileupload" name="myfile" type="file" />
<input type="submit" value="submit" id="submit" />
</form>
python 元素是这样的:
class Uploader(webapp2.RequestHandler):
def get(self):
objectname = '%s'%str(uuid.uuid4())
objectpath = '/gs/bucketname/%s' %objectname
upload = self.request.get('myfile')
writable = files.gs.create(filename=objectpath, mime_type='application/octet-stream', acl='public-read')
with files.open(writable, 'a') as f:
f.write(upload)
files.finalize(writable)
self.response.write('done')
我知道f.write(upload) 肯定是错的,但我不知道应该用什么替换它
【问题讨论】:
标签: google-app-engine google-cloud-storage google-api-python-client