I am trying to upload an object using SSE-Customer Provided Key and getting following Error.
botocore.exceptions.ClientError: An error occurred (InvalidObjectName) when calling the PutObject operation: Unknown
>>> s3.list_buckets()
{u'Owner': {u'DisplayName': 'User for deepscan testing', u'ID': 'deepscan'}, u'Buckets': [{u'CreationDate': datetime.datetime(2018, 12, 3, 23, 31, 54, 205000, tzinfo=tzutc()), u'Name': 'deepscan'}], 'ResponseMetadata': {'HTTPStatusCode': 200, 'RetryAttempts': 0, 'HostId': '', 'RequestId': 'tx000000000000000000019-005c1c6358-1035-default', 'HTTPHeaders': {'date': 'Fri, 21 Dec 2018 03:51:52 GMT', 'content-length': '329', 'x-amz-request-id': 'tx000000000000000000019-005c1c6358-1035-default', 'content-type': 'application/xml'}}}
>>> import os
>>> KEY = os.urandom(32)
>>> s3.put_object(Bucket='deepscan', Body=b'Just a long string piece of data', Key=KEY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 624, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidObjectName) when calling the PutObject operation: Unknown
Apart from above I also tried following put_object methods.
>>> s3.put_object(Bucket='deepscan', Key='encrypt-key',Body=b'foobar',SSECustomerKey=KEY,SSECustomerAlgorithm='AES256')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 624, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidRequest) when calling the PutObject operation: Unknown
>>> s3.put_object(Bucket='deepscan', Body='Just a long string piece of data', Key=KEY, Expires=datetime.datetime(2018, 12, 21), Metadata={'Mymeta1': '1', 'Mymeta2': '2'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 624, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidObjectName) when calling the PutObject operation: Unknown
>>> s3.put_object(Bucket='deepscan', Body='Just a long string piece of data', Key=KEY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 624, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidObjectName) when calling the PutObject operation: Unknown
I am referring to code example mentioned at:
Same example is given in boto3 examples doc.
From boto3/examples/s3.rst:
BUCKET = 'your-bucket-name'
KEY = os.urandom(32)
s3 = boto3.client('s3')
print("Uploading S3 object with SSE-C")
s3.put_object(Bucket=BUCKET,
Key='encrypt-key',
Body=b'foobar',
SSECustomerKey=KEY,
SSECustomerAlgorithm='AES256')
print("Done”)
Am I doing something wrong or missing anything?
Could someone please help what could be wrong and where to look for to further investigate this issue.
Regards,
Rishabh