谷歌雲存儲谷歌應用引擎(Python)使用任何代碼示例?谷歌雲存儲谷歌應用引擎(Python)
迄今爲止我見過的最好的是我從以前的問題,我發佈收到答覆:https://code.google.com/p/appengine-gcs-client/source/browse/trunk/python/demo/main.py
但是,代碼似乎成功運行不管如何連接,我似乎無法找到我的GCS桶中的文件
谷歌雲存儲谷歌應用引擎(Python)使用任何代碼示例?谷歌雲存儲谷歌應用引擎(Python)
迄今爲止我見過的最好的是我從以前的問題,我發佈收到答覆:https://code.google.com/p/appengine-gcs-client/source/browse/trunk/python/demo/main.py
但是,代碼似乎成功運行不管如何連接,我似乎無法找到我的GCS桶中的文件
main.py這個腳本直接上傳到GCS,通過改變create_upload_url函數和刪除gb_bucket_name它將使用blob存儲。
import os
import urllib
import webapp2
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
class MainHandler(webapp2.RequestHandler):
def get(self):
upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='bucket_name')
self.response.out.write('<html><body>')
self.response.out.write('<form action="%s" method="POST" enctype="multipart/form-data">' % upload_url)
self.response.out.write("""Upload File: <input type="file" name="file"><br> <input type="submit"
name="submit" value="Submit"> </form></body></html>""")
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads('file') # 'file' is file upload field in the form
blob_info = upload_files[0]
self.redirect('/serve/%s' % blob_info.key())
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self, resource):
resource = str(urllib.unquote(resource))
blob_info = blobstore.BlobInfo.get(resource)
self.send_blob(blob_info)
app = webapp2.WSGIApplication([('/', MainHandler),
('/upload', UploadHandler),
('/serve/([^/]+)?', ServeHandler)],
debug=True)
剛試過這個,沒有出現在GCS桶中。根據我看到的例子,似乎需要一些額外的配置,但不太確定。在下面的鏈接中運行示例代碼,即使我擺脫了最終刪除之後,該文件也不會顯示在GCS控制檯中...也不會完全上傳:https://cloud.google .COM/AppEngine上/文檔/蟒蛇/ Blob存儲/#Python_Using_the_Blobstore_API_with_Google_Cloud_Storage – Dennis 2014-10-08 05:37:04
http://upload.gae-init.appspot.com/resource/upload/ – Lipis 2014-10-07 19:12:21