App Engine到GCS |上传问题

时间:2013-07-11 13:51:52

标签: python google-app-engine google-cloud-storage

我有一些文件,我从Evernote API(通过getResource)收到并使用以下代码写入Google云端存储:

gcs_file = gcs.open(filename, 'w', content_type=res.mime,
                    retry_params=write_retry_params)

# Retrieve the binary data and write to GCS
resource_file = note_store.getResource(res.guid, True, False, False, False)
gcs_file.write(resource_file.data.body)

gcs_file.close()

对于某些类型的文档,它仍然有效。但是有些文件表明GCS会在日志中抛出这些文件:

Unable to fetch URL: https://storage.googleapis.com/evernoteresources/5db799f1-c03c-4056-812a-6d77bad55261/Sleep Away.mp3

Got exception while contacting GCS. Will retry in 0.11 seconds.

这些错误似乎没有任何模式。它发生在文档,声音,图片等等 - 这些文档类型中的一些有用,有些则不适用。这不是因为尺寸(因为一些小工作和一些大工作)。

有什么想法吗?


这里是完整的堆栈跟踪,但我不确定它会有所帮助。

Encountered unexpected error from ProtoRPC method implementation: TimeoutError (('Request to Google Cloud Storage timed out.', DownloadError('Unable to fetch URL: https://storage.googleapis.com/evernoteresources/78413585-2266-4426-b08c-71d6c224f266/Evernote Snapshot 20130512 124546.jpg',)))
Traceback (most recent call last):
  File "/python27_runtime/python27_lib/versions/1/protorpc/wsgi/service.py", line 181, in protorpc_service_app
    response = method(instance, request)
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/endpoints/api_config.py", line 972, in invoke_remote
    return remote_method(service_instance, request)
  File "/python27_runtime/python27_lib/versions/1/protorpc/remote.py", line 412, in invoke_remote_method
    response = method(service_instance, request)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/endpoints.py", line 61, in get_note_details
    url = tools.registerResource(note_store, req.note_guid, r)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/GlobalUtilities.py", line 109, in registerResource
    retry_params=write_retry_params)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/cloudstorage/cloudstorage_api.py", line 69, in open
    return storage_api.StreamingBuffer(api, filename, content_type, options)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/cloudstorage/storage_api.py", line 526, in __init__
    status, headers, _ = self._api.post_object(path, headers=headers)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/cloudstorage/rest_api.py", line 41, in sync_wrapper
    return future.get_result()
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 325, in get_result
    self.check_success()
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 368, in _help_tasklet_along
    value = gen.throw(exc.__class__, exc, tb)
  File "/base/data/home/apps/s~quinector/2a.368528733040360018/cloudstorage/storage_api.py", line 84, in do_request_async
    'Request to Google Cloud Storage timed out.', e)
TimeoutError: ('Request to Google Cloud Storage timed out.', DownloadError('Unable to fetch URL: https://storage.googleapis.com/evernoteresources/78413585-2266-4426-b08c-71d6c224f266/Evernote Snapshot 20130512 124546.jpg',))

2 个答案:

答案 0 :(得分:0)

谢谢Brian!问题是文件名中的空格。我只是使用urllib2.quote()来获取那些,它就像一个魅力。

答案 1 :(得分:0)

这是gcs客户端代码中的错误。它应该正确处理文件名。它使用http请求到GCS的事实应该是“隐藏的”。这将很快修复。谢谢!

请注意,如果您自己引用文件名以解决此错误,则修复后文件名将被双引号。遗憾。