Jeffgold commited on
Commit
5c42ee4
·
1 Parent(s): 9e0ee4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -93,13 +93,20 @@ def create_master_playlist(output_paths, input_filename):
93
  f.writelines(content)
94
  return master_playlist_path
95
 
96
- def upload_file_to_s3(file_path, s3_path):
97
- print(f"Uploading {file_path} to AWS at {s3_path}")
98
- with open(file_path, 'rb') as file:
99
- file_content = file.read()
 
 
 
100
 
101
- with fs.open(s3_path, 'wb') as file:
102
- file.write(file_content)
 
 
 
 
103
 
104
 
105
  def convert_video(video_file, quality, aspect_ratio, video_url):
 
93
  f.writelines(content)
94
  return master_playlist_path
95
 
96
+ def upload_file_to_s3(local_path, s3_key):
97
+ s3 = boto3.client(
98
+ "s3",
99
+ aws_access_key_id=st.secrets["AWS_ACCESS_KEY_ID"],
100
+ aws_secret_access_key=st.secrets["AWS_SECRET_ACCESS_KEY"],
101
+ region_name=st.secrets["AWS_REGION"],
102
+ )
103
 
104
+ bucket_name = st.secrets["AWS_S3_BUCKET"]
105
+
106
+ with open(local_path, "rb") as file:
107
+ s3.upload_fileobj(file, bucket_name, s3_key)
108
+
109
+ return f"https://{bucket_name}.s3.amazonaws.com/{s3_key}"
110
 
111
 
112
  def convert_video(video_file, quality, aspect_ratio, video_url):