我想在我的應用程序引擎項目上使用谷歌遠程API來上傳本地文件到我的應用程序的默認雲存儲桶。谷歌雲存儲客戶端與本地客戶端上的遠程API
我配置了我的app.yaml以啓用遠程API。我能夠訪問我的存儲桶並從中上傳/訪問文件。我跑我的Python的控制檯,並嘗試寫入桶用下面的代碼:
from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.api import app_identity
import cloudstorage
def auth_func():
return ('[email protected]', '*******')
remote_api_stub.ConfigureRemoteApi('my-app-id', '/_ah/remote_api', auth_func,'my-app-id.appspot.com')
filename = "/"+app_identity.get_default_gcs_bucket_name()+ "/myfile.txt"
gcs_file = cloudstorage.open(filename,'w',content_type='text/plain',options={'x-goog-meta-foo': 'foo','x-goog-meta-bar': 'bar'})
我看到下面的回覆:
WARNING:root:suspended generator urlfetch(context.py:1214) raised DownloadError(Unable to fetch URL: http://None/_ah/gcs/my-app-id.appspot.com/myfile.txt)
通知的
http://None/_ah/gcs.....
我不t認爲無應該是網址的一部分。 GoogleAppEngineCloudStorageClient v1.9.0.0有問題嗎?我也在使用Google App Engine 1.9.1。
任何想法?
'app_identity.get_default_gcs_bucket_name檢查您的環境()'是沒有得到設置看起來是這樣的。你能確認嗎? – Drewness
是的,它返回my-app-id.appspot.com – bvk
嘗試更改'filename =「/%s/myfile.txt」%app_identity.get_default_gcs_bucket_name()' – Drewness