It’s a Django project, I use django-storages and boto3. I use Amazon S3 to store files. Files are private, so a presigned URL is needed to access them.
How do I get X-Amz-Security-Token param with boto3 or django-storages?
This is the code is use to get presigned url:
client = boto3.client('s3',
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
region_name="eu-north-1")
file_path = "private/0001.dcm" // copied directly from Amazon bucket account on key value
response = client.generate_presigned_url('get_object',
Params={'Bucket': BUCKET_NAME,
'Key': file_path},
HttpMethod="GET",
ExpiresIn=EXPIRES_IN)
The URL I get with this code is short, X-Amz-Security-Token and it doesn’t work.
The presigned URL I get on my Amazon account is very long and it works fine.
How do I get presigned url with X-Amz-Security-Token in Python?