使用AWS上传到S3时出现307(临时重定向)错误

时间:2015-10-23 04:35:15

标签: amazon-web-services amazon-s3

我在将文件上传到S3时遇到错误:

$ aws s3 cp myfile.CSV s3://mybucket
upload failed: ./myfile.CSV to s3://mybucket/myfile.CSV
An error occurred (307) when calling the UploadPart operation: Temporary Redirect
Completed 51 of 167 part(s) with -6 file(s) remaining

我以前能够将同一台机器上同一目录中的文件上传到同一个存储桶,没有任何问题。

现在我无法上传这些文件。它们只是普通的CSV文件,每个大约1.2GB。

使用--debug运行我看到以下内容:

015-10-23 04:32:40,743 - Thread-13 - botocore.hooks - DEBUG - Event needs-retry.s3.UploadPart: calling handler <botocore.retryhandler.RetryHandler object at 0x303f9d0>
2015-10-23 04:32:40,743 - Thread-13 - botocore.retryhandler - DEBUG - No retry needed.
2015-10-23 04:32:40,743 - Thread-13 - botocore.hooks - DEBUG - Event after-call.s3.UploadPart: calling handler <function enhance_error_msg at 0x2874cf8>
2015-10-23 04:32:40,743 - Thread-13 - botocore.hooks - DEBUG - Event after-call.s3.UploadPart: calling handler <awscli.errorhandler.ErrorHandler object at 0x2920590>
2015-10-23 04:32:40,743 - Thread-13 - awscli.errorhandler - DEBUG - HTTP Response Code: 307
2015-10-23 04:32:40,743 - Thread-13 - awscli.customizations.s3.tasks - DEBUG - Error during part upload: An error occurred (307) when calling the UploadPart operation: Temporary Redirect
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/awscli/customizations/s3/tasks.py", line 235, in __call__
    response_data = self._filename.client.upload_part(**params)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 301, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 386, in _make_api_call
    raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (307) when calling the UploadPart operation: Temporary Redirect
2015-10-23 04:32:40,744 - Thread-1 - awscli.customizations.s3.executor - DEBUG - Received print task: PrintTask(message=u'upload failed: ...nAn error occurred (307) when calling the UploadPart operation: Temporary Redirect', error=True, total_parts=None, warning=None)
upload failed: ....
An error occurred (307) when calling the UploadPart operation: Temporary Redirect
2015-10-23 04:32:40,744 - Thread-13 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2015-10-23 04:32:40,992 - Thread-11 - botocore.vendored.requests.packages.urllib3.connectionpool - DEBUG - "PUT ...
2015-10-23 04:32:40,993 - Thread-11 - botocore.parsers - DEBUG - Response body:
...
2015-10-23 04:32:41,270 - Thread-9 - botocore.parsers - DEBUG - Exception caught when parsing error response body:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/botocore/parsers.py", line 686, in _do_error_parse
    return self._parse_error_from_body(response)
  File "/usr/local/lib/python2.7/dist-packages/botocore/parsers.py", line 708, in _parse_error_from_body
    root = self._parse_xml_string_to_dom(xml_contents)
  File "/usr/local/lib/python2.7/dist-packages/botocore/parsers.py", line 346, in _parse_xml_string_to_dom
    "invalid XML received:\n%s" % (e, xml_string))
ResponseParserError: Unable to parse response (syntax error: line 1, column 0), invalid XML received:
x-amz-id-2: xxxxx
x-amz-request-id: xxxxxx
Date: Fri, 23 Oct 2015 04:32:35 GMT
ETag: "xxxxx"
Content-Length: 0
Server: AmazonS3

1 个答案:

答案 0 :(得分:0)

通过指定与您的存储桶位置匹配的区域来配置您的aws-cli设置:

$ aws configure
AWS Access Key ID [********************]:
AWS Secret Access Key [********************]:
Default region name [*********]: eu-west-1
Default output format [None]:

然后再次尝试aws s3 cp命令。