I have some images in my S3 bucket and I want to display them in my django application.
import boto3
s3=boto3.client('s3')
list=s3.list_objects(Bucket='my_bucket_name')['Contents']
for l in list:
print(l[u'Key'])
Using this code I'm getting the names of those images. How do I get the URL of the images, so that I can pass it to HTML pages to display it, using this same approach?
URLs to access files in S3 follow this format:
See here: https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAPI.html
And then utilize the django Template language (see here: https://docs.djangoproject.com/en/2.0/ref/templates/language/#) to inject what you need.
If your buckets were stored in a list, and keys for for each bucket were stored in a dictionary, you could do something like this: