我发现了一个错误,如下所示。
INFO ~ module.py:639] default: "HEAD /_ah/gcs/app_default_bucket/multibytes.txt HTTP/1.1" 404 -
ERROR ~ gcs.py:99] Expect status [200] from Google Storage. But got status 404.
Path: '/app_default_bucket/multibytes.txt'.
Request headers: None.
Response headers: {'date': 'Mon, 07 Jul 2014 12:59:44 GMT', 'server': 'Development/2.0', 'connection': 'close'}.
Body: ''.
Extra info: None.
Traceback (most recent call last):
File "/gcs.py", line 97, in status
stat = gcs.stat("/%s/%s" % (b,nm))
File "/cloudstorage/cloudstorage_api.py", line 142, in stat
body=content)
File "/cloudstorage/errors.py", line 132, in check_status
raise NotFoundError(msg)
NotFoundError: Expect status [200] from Google Storage. But got status 404.
Path: '/app_default_bucket/multibytes.txt'.
Request headers: None.
Response headers: {'date': 'Mon, 07 Jul 2014 12:59:44 GMT', 'server': 'Development/2.0', 'connection': 'close'}.
Body: ''.
Extra info: None.
例如,这是我的自定义 GCS 客户端类。
# encoding: utf-8
import cloudstorage as gcs
class mycustomgcsclient:
#...
def create(self,name,data,**options):
options['retry_params'] = gcs.RetryParams(backoff_factor=1.1)
if not options.get('content_type'):
options['content_type'] = 'octet-stream'
if isintance(name,unicode):
name = name.encode('utf-8')
path = '/mybucketname/%s' % name
try:
with gcs.open(path,'w',**options) as f:
f.write(data)
return True
except Exception as e:
logging.exception(e)
return False
if __name__=='__main__':
data = 'some data ...¥n'
filename = 'somedir/%s' % u'sample.txt'
mycustomgcsclient().create(filename,data) # no error occured.
filename = 'somedir/%s' % u'あいうえお.txt'
mycustomgcsclient().create(filename,data) # error occured in this line.
仅使用多字节文件名时,我在上面发现了一个错误。
使用 ascii 的文件名时,我没有发现任何错误。
我正在使用https://developers.google.com/appengine/docs/python/googlecloudstorageclient/download上提供的“GCS 客户端库(Python)” 。
我的 dev_appserver.py 版本是 Development SDK 1.9.6,这适用于 MacOS X Marve ..(?忘记了)。
有一些解决方案吗?