-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (19 loc) · 780 Bytes
/
test.py
File metadata and controls
25 lines (19 loc) · 780 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
import boto3
import mimetypes
import uuid
import os
def uuid_file_path(filename):
if filename:
ext = filename.split('.')[-1]
else:
ext = "png"
filename = "%s.%s" % (uuid.uuid4(), ext)
return os.path.join(filename)
path = "/home/ts/Documents/projects/python-base/codes/faceswap/media/result1.mp4"
s3_client = boto3.client(
's3', aws_access_key_id="AKIAYMPAXPYXGBUSLCO6", aws_secret_access_key="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")
s3_key = 'video/upload/{0}'.format(uuid_file_path(path))
content_type, _ = mimetypes.guess_type(s3_key)
s3_client.upload_file(path, "sfappv2", s3_key,
ExtraArgs={'ACL': 'public-read', 'ContentType': content_type})
print(f'https://s3.amazonaws.com/sfappv2/{s3_key}')