Добавил новые ЭП для новой версии загрузки видео с YouTube
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
from urllib.parse import quote
|
||||
|
||||
import boto3
|
||||
from botocore.client import Config
|
||||
@@ -180,9 +181,10 @@ class S3UploadBackend(UploadBackend):
|
||||
self.key_prefix = key_prefix
|
||||
|
||||
def upload(self, name: str, file: bytes | str):
|
||||
response = self.s3.upload_file(
|
||||
Filename=file,
|
||||
Bucket=self.bucket,
|
||||
Key=f"{self.key_prefix}{name}",
|
||||
)
|
||||
return response["Location"]
|
||||
key = f"{self.key_prefix}{name}"
|
||||
if isinstance(file, str):
|
||||
self.s3.upload_file(Filename=file, Bucket=self.bucket, Key=key)
|
||||
else:
|
||||
self.s3.put_object(Bucket=self.bucket, Key=key, Body=file)
|
||||
encoded_key = quote(key, "")
|
||||
return f"{settings.S3_ENDPOINT_URL}/{self.bucket}/{encoded_key}"
|
||||
|
||||
Reference in New Issue
Block a user