steeldonutcollection/backend/s3.py
2022-05-05 17:40:57 +02:00

18 lines
No EOL
466 B
Python

from minio import Minio
from minio.error import S3Error
from django.conf import settings
from datetime import timedelta
def build_s3_from_settings():
return Minio(
endpoint = settings.S3_ENDPOINT,
access_key= settings.S3_ACCESS_KEY,
secret_key= settings.S3_SECRET_KEY
)
def build_presigned_url(path, validity=timedelta(hours=12)):
s3 = build_s3_from_settings()
return s3.get_presigned_url("GET", settings.S3_BUCKET, path)