2
我創建的斑點在GAE BLOBSTORE和successfuly創建這些文件,問題是,當我嘗試使用的BlobKey爲這些文件,我得到了內容長度= 0,因爲這樣:BLOB的Blob存儲在GAE
Status: 200 OK
Cache-Control: no-cache
X-AppEngine-BlobKey: crXwVb6vKoS8OykvgPmSew==
Content-Type: application/zip
Content-Disposition: attachment; filename="test.zip"
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0
這樣(test.zip)是在BlobStore中創建的文件,我在管理控制檯中檢查了BlobStore併成功創建了此文件。 編輯: download.py代碼:
def mime_type(filename):
return guess_type(filename)[0]
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self):
blob_key = self.request.get('key')
blob_key = str(urllib.unquote(blob_key))
blob_info = blobstore.BlobInfo.get(blob_key)
content_type1 =mime_type(blob_info.filename)
save_as1 = blob_info.filename
self.send_blob(blob_key,content_type=content_type1,save_as=save_as1)
def main():
application = webapp.WSGIApplication([
(r'/download.*', ServeHandler),
], debug=True)
run_wsgi_app(application)
if __name__ == '__main__':
main()
關鍵是在URL中存在如下:
http://localhost:8080/download.py?key=Es9f00P29wNTZoeL9ccS4g==
,我得到它得到Blob存儲團塊。
在此先感謝。
你能告訴處理程序? – 2012-03-31 09:11:23
@Peter Knego:好的,我會編輯這個問題。 – 2012-03-31 09:51:29
你從哪裏得到blobkey?它看起來像是Base64編碼的。 – 2012-03-31 12:32:10