Browse Source

更新 share_url
更新 logo.png

罗俊辉 1 năm trước cách đây
mục cha
commit
b843dbdfc5
1 tập tin đã thay đổi với 1 bổ sung6 xóa
  1. 1 6
      applications/functions/upload.py

+ 1 - 6
applications/functions/upload.py

@@ -46,15 +46,10 @@ async def upload_to_oss(video_id, video_url):
     print("start download video...")
     await download_video(video_url, "temp.mp4")
     print("video download successfully done")
-    with open("temp.mp4", "rb") as file:
-        file_content = file.read()
-    print("读取完成")
-    content_type = 'application/octet-stream'
     oss_object_key = f'single_video/{video_id}'
     auth = oss2.Auth(OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET)
     bucket = oss2.Bucket(auth, OSS_BUCKET_ENDPOINT, "art-pubbucket")
-    response = bucket.put_object(oss_object_key, file_content, headers={'Content-Type': content_type})
-    print(response.status)
+    response = bucket.put_object_from_file(oss_object_key, "temp.mp4")
     if 'Content-Length' in response.headers:
         return {
             'status': response.status,