Reputation: 544
I'm using a Django User models to store my users. My user will have the usual: name, username, password.
Here's an example:
class UserProfile(models.Model):
user = models.OneToOneField(User, primary_key=True)
photo_url = models.CharField(max_length=200, blank=True, default='') # the url to fetch photo
There will be one field that I will need to generate a url for and that is the url for the photo he uploaded to S3, that way my client can download it and display it.
What's the best way to generate an indefinite url in boto3?
Upvotes: 0
Views: 298
Reputation: 1
actually we cannot create a presigned url without expiration ,the maximum period of expiration is one week for S3 version 4 and for v2 it might be higher .
Upvotes: 0
Reputation: 52433
From: Generating Presigned URLs. There is no way to specify a non-expiring URL. Use a large int value for ExpiresIn
parameter. Try it.
import boto3
import requests
# Get the service client.
s3 = boto3.client('s3')
# Generate the URL to get 'key-name' from 'bucket-name'
url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': 'bucket-name',
'Key': 'key-name'
},
ExpiresIn=9999999999
)
Upvotes: 2