10👍
✅
Turns out you do not need to use boto3 to generate a presigned url. Django-storages abstracts the entire process. You can simply generate it as follows docfile.url
.
— Edit —-
For reference, here is the S3 storage class method that generates the pre-signed url for you
https://github.com/jschneier/django-storages/blob/770332b598712da27ecdba75c9e202ad6a1a8722/storages/backends/s3boto3.py#L554
3👍
Here is sample code for generating pre-signed url for object in S3
import boto3
client = boto3.client('s3')
response = client.generate_presigned_url('get_object',Params={'Bucket': bucket_name,
'Key': objectpath},
HttpMethod="GET", ExpiresIn=expires_in)
Source:stackexchange.com