相关疑难解决方法(0)

调用 PutObject 操作时的 PermanentRedirect

下面的代码在本地运行并将文件从目录上传到 S3。它使用 Boto3 和 Python 3。

s3 = boto3.resource('s3', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_ACCESS_KEY_SECRET)
bucket = s3.Bucket(bucket_name)
uploadFileNames = []
for (sourceDir, dirname, filenames) in os.walk(sourceDir):
    for filename in filenames:
        bucket.put_object(Key=filename, Body=open("{}{}".format(sourceDir, filename), "rb"))
    break
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我在生产服务器(Ubuntu)上运行相同的代码时,出现以下错误,为什么?

    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.4/site-packages/botocore/client.py", line 335, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (PermanentRedirect) when calling the PutObject operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
Run Code Online (Sandbox Code Playgroud)

再次在我的 Mac 本地,此代码可以工作,但仅在我的 …

python amazon-s3 boto amazon-web-services python-3.x

2
推荐指数
1
解决办法
4128
查看次数