0

我有一些从 Evernote API 接收的文件(通过getResource)并使用以下代码写入 Google Cloud Storage:

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',))
4

2 回答 2

0

谢谢布赖恩!问题是文件名中的空格。我只是过去常常urllib2.quote()让那些离开那里,它就像一个魅力。

于 2013-07-11T17:37:27.527 回答
0

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

请注意,如果您自己引用文件名来解决此错误,则在修复后文件名将被双引号引起来。对不起。

于 2013-07-11T19:10:32.277 回答