dev-resources.site
for different kinds of informations.
Cloudflare R2 - Generating Presigned URL
Published at
7/30/2022
Categories
cloudflare
r2
python
Author
shrawanx
Author
8 person written this
shrawanx
open
Since, cloudflare R2 is compatible with S3 API, we can simply use boto3 to work with R2 as wll
import logging
import boto3
from botocore.exceptions import ClientError
from botocore.client import Config
def create_presigned_url(bucket_name, object_name, expiration=3600):
s3_client = boto3.client('s3',
endpoint_url='https://<ACCOUNT_ID>.r2.cloudflarestorage.com',
aws_access_key_id='<ACCESS_KEY>',
aws_secret_access_key='<SECRET_KEY>',
config=Config(signature_version='s3v4'),
)
try:
response = s3_client.generate_presigned_url('get_object',
Params={'Bucket': bucket_name,
'Key': object_name},
ExpiresIn=expiration)
except ClientError as e:
logging.error(e)
return None
# The response contains the presigned URL
return response
if you want to use R2 with Django have a look into https://djangotherightway.com/using-cloudflare-r2-with-django-for-storage
r2 Article's
8 articles in total
Why is There So Much Hype about the Workday R2 Release
read article
Streamlining Efficiency: The Power of Workday Test Automation for the R2 Release
read article
Reasons Behind the Increasing Popularity of Workday R2 Release
read article
Next.js: Upload de imagem para a Cloudflare R2 Utilizando Presigned URL
read article
Reducing egress costs for dummies (R2 vs S3)
read article
Hosting static sites with Cloudflare R2 and MinIO Client
read article
How To Fix - CORS Error while uploading files on Cloudflare R2 using presigned URLs.
read article
Cloudflare R2 - Generating Presigned URL
currently reading
Featured ones: