0

我试图从我的应用程序引擎应用程序上传到云存储,但它不断上传文件的名称而不是其内容。上传到Google Cloud Storage

的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> 

蟒蛇元素是这样的:

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)肯定是不对的,但我不知道我应该代替它与

回答

1

它需要POST不GET,所以添加method="POST"到窗体并使python函数发布,而不是得到太多,为我整理出来。

相关问题