bucket = s3client.create_bucket(Bucket='my-new-shiny-bucket')
response = s3client.list_buckets()
for bucket in response["Buckets"]:
- print "{name}\t{created}".format(
+ print("{name}\t{created}".format(
name = bucket['Name'],
created = bucket['CreationDate'],
- )
+ ))
Similar steps can be performed for using GetSessionToken with LDAP.
.. code-block:: python
for bucket in conn.get_all_buckets():
- print "{name}\t{created}".format(
+ print("{name}\t{created}".format(
name = bucket.name,
created = bucket.creation_date,
- )
+ ))
The output will look something like this::
.. code-block:: python
for key in bucket.list():
- print "{name}\t{size}\t{modified}".format(
+ print("{name}\t{size}\t{modified}".format(
name = key.name,
size = key.size,
modified = key.last_modified,
- )
+ ))
The output will look something like this::
hello_key = bucket.get_key('hello.txt')
hello_url = hello_key.generate_url(0, query_auth=False, force_http=True)
- print hello_url
+ print(hello_url)
plans_key = bucket.get_key('secret_plans.txt')
plans_url = plans_key.generate_url(3600, query_auth=True, force_http=True)
- print plans_url
+ print(plans_url)
The output of this will look something like::
.. code-block:: python
- print conn.list_objects(Bucket='my-new-bucket', AllowUnordered=True)
+ print(conn.list_objects(Bucket='my-new-bucket', AllowUnordered=True))
Without the extensions file, in the above example, boto3 would complain that the ``AllowUnordered`` argument is invalid.
.. code-block:: python
for container in conn.get_account()[1]:
- print container['name']
+ print(container['name'])
The output will look something like this::
.. code-block:: python
for data in conn.get_container(container_name)[1]:
- print '{0}\t{1}\t{2}'.format(data['name'], data['bytes'], data['last_modified'])
+ print('{0}\t{1}\t{2}'.format(data['name'], data['bytes'], data['last_modified']))
The output will look something like this::
sig = hmac.new(key, hmac_body, sha1).hexdigest()
rest_uri = "{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}".format(
host=host, path=path, sig=sig, expires=expires)
- print rest_uri
+ print(rest_uri)
# Example Output
# https://objectstore.example.com/swift/v1/your-bucket/your-object?temp_url_sig=ff4657876227fc6025f04fcf1e82818266d022c6&temp_url_expires=1423200992