Commit 2fc81705 authored by Christian Salzmann-Jaeckel's avatar Christian Salzmann-Jaeckel
Browse files

add s3-list-objects.py

parent 981704cd
#!/usr/bin/python3
import os
import logging
import boto3
radosgw_access_key = os.environ['AWS_ACCESS_KEY_ID']
radosgw_secret_key = os.environ['AWS_SECRET_ACCESS_KEY']
radosgw_endpoint_url = 'https://rise-s3.zib.de'
radosgw_bucket_name = 'py3-boto-bucket'
radosgw_key_name = 'upload_file'
radosgw_file_name = 'example.txt'
# generate s3 client
s3_client = boto3.client('s3',
endpoint_url=radosgw_endpoint_url,
aws_access_key_id=radosgw_access_key,
aws_secret_access_key=radosgw_secret_key
)
# generate s3 resource
s3_resource = boto3.resource('s3',
endpoint_url=radosgw_endpoint_url,
aws_access_key_id=radosgw_access_key,
aws_secret_access_key=radosgw_secret_key
)
# generate download url
url = s3_client.generate_presigned_url('get_object', Params = {'Bucket': radosgw_bucket_name, 'Key': radosgw_key_name}, ExpiresIn = 100)
print(url)
# list objects
response = s3_client.list_objects_v2(Bucket=radosgw_bucket_name)
print('')
for item in response['Contents']:
print(item['Key'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment