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函數發佈,而不是得到太多,爲我整理出來。

相關問題