【发布时间】:2014-07-07 13:59:01
【问题描述】:
我发现如下错误。
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..(?忘记了)。
有什么解决办法吗?
【问题讨论】:
-
您好,能否提供一个示例代码来说明问题?
-
另外,似乎一开始就找不到多字节文件。您能否在创建后验证该文件是否确实存在?在 dev_appserver 上,您应该能够在 blobstore 查看器中看到它:localhost:8000/blobstore 在应用引擎本身上,您可以在 Cloud Storage 的存储浏览器中看到它们:console.developers.google.com/project/apps~YOURAPPIDHERE/…
-
谢谢大家。我添加了我的源代码。
-
我无法验证存储的数据,因为存储事务未完成。错误发生在 GAE 或 GCS 库内部运行的“/_ah/~”请求中。
标签: python google-app-engine google-cloud-storage dev-appserver dev-appserver-2