I'm really keen to try this module out but a bit stumpted as to the
basic syntax. Can you clarify how to do use this in relation to the
Amazone S3 get started guide? Using Getting Started Guide (API Version
2006-03-01)
e.g.
<code>
# all future examples assume this:
conn = S3.AWSAuthConnection("[aws-access-key-id]",
"[aws-secret-access-key]")
response = conn.create_bucket("[bucket-name]")
if response.http_response.status == 200:
# bucket was created
else:
# something bad happened
</code>
I tried
<code>
>>> import s3
>>> connection = s3.S3Connection('<amazon user id>', '<secret key>')
>>> connection
<s3.connection.S3Connection object at 0xb78b3fcc>
>>> response = connection.create_bucket("mynewbucket")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "s3/connection.py", line 128, in f
raise parseError(r.read())
s3.errors.S3Error: S3Error: NoSuchBucket - The specified bucket does
not exist
</code>
Looking at the docs that came with the module, not clear what this last
error means.
Any help appreciated.
Thanks
.M.
$ python
>>> import s3
>>> service = s3.Service(self, pub_key, priv_key)
>>> bucket = service.create(name='MyBucket')
>>> service.list()
>>> object = s3.S3Object(key='myKey', data='my data', metadata={})
>>> bucket.save(object)
>>> bucket.list()
> $ python
> >>> import s3
> >>> service = s3.Service(self, pub_key, priv_key)
This didn't work but this did
service = s3.Service(pub_key, priv_key)
> >>> bucket = service.create(name='MyBucket')
> >>> service.list()
> >>> object = s3.S3Object(key='myKey', data='my data', metadata={})
how is metadata supposed to be expressed? Standard dictionary syntax
doesn't appear to work.
>>> object = s3.S3Object(key='testing2', data='my data', metadata={'user_id':1})
>>> bucket.save(object)Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "s3/objects.py", line 161, in save
self._request('PUT', s3object.key, send_io=data, headers=headers)
File "s3/objects.py", line 66, in _request
params=params, headers=headers,
File "s3/connection.py", line 97, in f
headers = self._headers(method, path, length=length,
headers=headers)
File "s3/connection.py", line 62, in _headers
headers["Authorization"] = self._auth_header_value(method, path,
headers)
File "s3/connection.py", line 48, in _auth_header_value
auth_parts.extend([k + ":" + headers[k].strip() for k in xamzs])
AttributeError: 'int' object has no attribute 'strip'
> This didn't work but this did
>
> service = s3.Service(pub_key, priv_key)
Metadata should be a dictionary of strings. So both the key and the
value must be a string.