我想使用以下代码将文件上传到s3云:
session = boto3.session.Session()
s3_client = session.resource('s3',
endpoint_url=credentials.get('endpoint_url'),
aws_access_key_id=credentials.get('access_key'),
aws_secret_access_key=credentials.get('secret_key'),
)
bucket = s3_client.Bucket("test")
bucket.upload_file("req.txt", "req.txt")
我得到这个错误:
boto3.exceptions.S3UploadFailedError: Failed to upload req.txt to test/req.txt: An error occurred (404) when calling the PutObject operation: Not Found
另外,我正在使用以下代码:
session = boto3.session.Session()
s3_client = session.client(service_name='s3',
endpoint_url=credentials.get('endpoint_url'),
aws_access_key_id=credentials.get('access_key'),
aws_secret_access_key=credentials.get('secret_key'),
)
def upload_file(filename, bucket_name, name_in_bucket):
s3_client.upload_file(filename, bucket_name, name_in_bucket)
upload_file('req.txt', 'test_mmdaz', 'testfile.txt')
,我得到同样的错误。 任何想法:?
答案 0 :(得分:0)
根据@RobertoS的评论,我的错是存储桶:?src=abb_fh_uit*_source=h&_medium=cpm&my_campaign=abb_hc_hr
src=abb_fh_uit*_source=h&_medium=cpm&my_campaign=goal_healthcare
?src=abb_fh_uit*_source=h&_medium=cpm&my_campaign=goal_hr
?src=abb_fh_uit*_source=h&_medium=cpm&my_campaign=abb_hr_healthcare
不在我的s3云对象服务中。