blob 이미지 업로드 완료
This commit is contained in:
1 parent
6917a76d60
commit
12e6f7357c
8 files changed
+756
-447
No files matched your search
@@ -1,14 +1,18 @@
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
SAS_TOKEN = "sp=racwdl&st=2025-12-01T00:13:29Z&se=2026-07-31T08:28:29Z&spr=https&sv=2024-11-04&sr=c&sig=7fE2ozVBPu3Gq43%2FZDxEYdEcPLDXyNVfTf16IBasmVQ%3D"
|
||||
|
||||
def upload_music_to_azure_blob(file_path = "스테이 머뭄_1.mp3", url = "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.mp3"):
|
||||
URL = "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/"
|
||||
|
||||
|
||||
def upload_music_to_azure_blob(
|
||||
file_path="스테이 머뭄_1.mp3",
|
||||
url="https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.mp3",
|
||||
):
|
||||
access_url = f"{url}?{SAS_TOKEN}"
|
||||
headers = {
|
||||
"Content-Type": "audio/mpeg",
|
||||
"x-ms-blob-type": "BlockBlob"
|
||||
}
|
||||
headers = {"Content-Type": "audio/mpeg", "x-ms-blob-type": "BlockBlob"}
|
||||
with open(file_path, "rb") as file:
|
||||
response = requests.put(access_url, data=file, headers=headers)
|
||||
if response.status_code in [200, 201]:
|
||||
@@ -17,15 +21,16 @@ def upload_music_to_azure_blob(file_path = "스테이 머뭄_1.mp3", url = "http
|
||||
print(f"Failed Status Code: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
def upload_video_to_azure_blob(file_path = "스테이 머뭄.mp4", url = "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.mp4"):
|
||||
|
||||
def upload_video_to_azure_blob(
|
||||
file_path="스테이 머뭄.mp4",
|
||||
url="https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.mp4",
|
||||
):
|
||||
access_url = f"{url}?{SAS_TOKEN}"
|
||||
headers = {
|
||||
"Content-Type": "video/mp4",
|
||||
"x-ms-blob-type": "BlockBlob"
|
||||
}
|
||||
headers = {"Content-Type": "video/mp4", "x-ms-blob-type": "BlockBlob"}
|
||||
with open(file_path, "rb") as file:
|
||||
response = requests.put(access_url, data=file, headers=headers)
|
||||
|
||||
|
||||
if response.status_code in [200, 201]:
|
||||
print(f"Success Status Code: {response.status_code}")
|
||||
else:
|
||||
@@ -33,7 +38,10 @@ def upload_video_to_azure_blob(file_path = "스테이 머뭄.mp4", url = "https:
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
|
||||
def upload_image_to_azure_blob(file_path = "스테이 머뭄.png", url = "https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.png"):
|
||||
def upload_image_to_azure_blob(
|
||||
file_path="스테이 머뭄.png",
|
||||
url="https://ado2mediastoragepublic.blob.core.windows.net/ado2-media-public-access/ado2-media-original/dev-user-idx/dev-task-idx/test_my_mp3_should_now_exist.png",
|
||||
):
|
||||
access_url = f"{url}?{SAS_TOKEN}"
|
||||
extension = Path(file_path).suffix.lower()
|
||||
content_types = {
|
||||
@@ -42,23 +50,20 @@ def upload_image_to_azure_blob(file_path = "스테이 머뭄.png", url = "https:
|
||||
".png": "image/png",
|
||||
".gif": "image/gif",
|
||||
".webp": "image/webp",
|
||||
".bmp": "image/bmp"
|
||||
".bmp": "image/bmp",
|
||||
}
|
||||
content_type = content_types.get(extension, "image/jpeg")
|
||||
headers = {
|
||||
"Content-Type": content_type,
|
||||
"x-ms-blob-type": "BlockBlob"
|
||||
}
|
||||
headers = {"Content-Type": content_type, "x-ms-blob-type": "BlockBlob"}
|
||||
with open(file_path, "rb") as file:
|
||||
response = requests.put(access_url, data=file, headers=headers)
|
||||
|
||||
|
||||
if response.status_code in [200, 201]:
|
||||
print(f"Success Status Code: {response.status_code}")
|
||||
else:
|
||||
print(f"Failed Status Code: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
|
||||
|
||||
upload_video_to_azure_blob()
|
||||
|
||||
upload_image_to_azure_blob()
|
||||
upload_image_to_azure_blob()
|
||||
Reference in new issue
Block a user