-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy paths3.py
More file actions
28 lines (22 loc) · 729 Bytes
/
s3.py
File metadata and controls
28 lines (22 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import minio
def get_minio_client(settings):
client = minio.Minio(
's3.amazonaws.com',
access_key=settings.AWS_ACCESS_KEY_ID,
secret_key=settings.AWS_SECRET_ACCESS_KEY,
region=settings.AWS_REGION
)
return client
def create_presigned_url(settings, bucket_name, object_name):
"""Generate a presigned URL to share an S3 object
:param bucket_name: string
:param object_name: string
:return: Presigned URL as string. If error, returns None.
"""
# Generate a presigned URL for the S3 object
client = get_minio_client(settings)
return client.get_presigned_url(
method='GET',
bucket_name=bucket_name,
object_name=object_name
)