I want to create Quick Share link, for an individual file on digital ocean spaces so that Anyone with the link will be able to view a private file during the specified time interval. I am using Django . An assistance will be appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You can create a “Quick Share link” by generating a “pre-signed” URL using boto3 or another Python client library for S3-compatible object storage services.
With boto3, you first need to configure your session:
import os
import boto3
from botocore.client import Config
session = boto3.session.Session()
key = os.getenv('SPACES_KEY')
secret = os.getenv('SPACES_SECRET')
client = session.client('s3',
region_name='nyc3',
endpoint_url='https://nyc3.digitaloceanspaces.com',
aws_access_key_id=key,
aws_secret_access_key=secret)
Then you can generate a functioning pre-signed url using:
url = client.generate_presigned_url(ClientMethod='get_object',
Params={'Bucket': 'my-space',
'Key': 'my-file'},
ExpiresIn=300)
Note the ExpiresIn argument. By default, pre-signed URLs will expire in an hour (3600 seconds). This example sets it to expire in 5 minutes. See the boto3 docs for more info.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.