我正在尝试将带有boto3的照片上传到s3存储桶。我似乎无法正常工作。以下代码:

时间:2018-10-24 14:17:03

标签: boto3

我正在尝试将带有boto3的照片上传到s3存储桶。我似乎无法正常工作。我的代码:

import boto3
from botocore.client import Config


s3 = boto3.resource('s3',
    aws_access_key_id='xxxxxxx',
    aws_secret_access_key='xxxx',
    config=Config(signature_version='s3v4')

)
data = open("bbb.jpg", "rb")
s3.Bucket('indstudyphotos').put_object(Key="bbb.jpg", Body=data) 

我不断收到错误消息:AttributeError:'模块'对象没有属性'parse_header'

任何帮助将不胜感激。

这是回溯:

Traceback (most recent call last):  File "/Users/joe/testPyFile.py", line 20, in <module>
s3.Bucket('indstudyphotos').put_object(Key="bbb.jpg", Body=data  File "/Library/Python/2.7/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)File "/Library/Python/2.7/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/client.py", line 324, in _api_call
return self._make_api_call(operation_name, kwargs) File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/client.py", line 609, in _make_api_call
operation_model, request_dict)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/endpoint.py", line 143, in make_request
return self._send_request(request_dict, operation_model)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/endpoint.py", line 172, in _send_request
success_response, exception):  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/endpoint.py", line 265, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/hooks.py", line 227, in emit
return self._emit(event_name, kwargs)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/hooks.py", line 210, in _emit
response = handler(**kwargs)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 269, in _should_retry
return self._checker(attempt_number, response, caught_exception)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)  File "/Users/joe/Library/Python/2.7/lib/python/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception AttributeError: 'module' object has no attribute 'parse_header'
  
    
      

    
  

0 个答案:

没有答案