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

브라우저를 GCS로 직접 업로드하고 나중에 호출되는 처리기 만 가져야합니다.

는이 작업을 수행 할 수있는 방법에 대한 간단한 개요를 얻으려면,이 게시물보고 : Blob 저장소 API는이 예에서 호출 할 것으로 보인다 Upload images/video to google cloud storage using Google App Engine

경우에도 파일을 클라우드 스토리지에 업로드됩니다.

1

POST가 필요하지 않으므로 양식에 method="POST"을 추가하고 파이썬 함수가 POST 대신 나옵니다.