我想在將它上傳到Google App Engine Blobstore之前先加密一個斑點。Google App Engine:上傳前加密斑點
這裏是我有哪裏的urllib2試圖發佈請求的最後一行的問題處理
class MyUploadHandler(webapp2.RequestHandler):
def post(self):
upload_url = blobstore.create_upload_url('/myAfterUploadHandler')
inFile = self.request.POST.multi['file'].file
outFile = StringIO.StringIO()
encryptFile(inFile,outFile,DATAKEY)
datagen, headers = multipart_encode({"file": outFile})
request = urllib2.Request(upload_url, \
datagen, headers)
self.response = urllib2.urlopen(request)
。
這裏是長異常的最後單方面
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 270, in fetch
allow_truncated, follow_redirects, validate_certificate)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 326, in make_fetch_call
request.set_payload(payload)
File "cpp_message.pyx", line 124, in cpp_message.SetScalarAccessors.Setter (third_party/apphosting/python/protobuf/proto1/cpp_message.cc:2229)
TypeError: <type 'instance'> has type <type 'instance'>, but expected one of: str, unicode
如果可能,不是針對該特定問題的答案,但我建議您使用[Python雲端存儲客戶端](https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/)。 –
這是我的要點,顯示了應用程序如何將blob發送到blobstore。 https://gist.github.com/voscausa/9222732 – voscausa
@voscausa謝謝!你認爲GCS會更好嗎?我真的在考慮海梅建議 – Sindico