import requests from pathlib import Path 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"): access_url = f"{url}?{SAS_TOKEN}" 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]: print(f"Success Status Code: {response.status_code}") else: 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"): access_url = f"{url}?{SAS_TOKEN}" 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: print(f"Failed Status Code: {response.status_code}") 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"): access_url = f"{url}?{SAS_TOKEN}" extension = Path(file_path).suffix.lower() content_types = { ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".png": "image/png", ".gif": "image/gif", ".webp": "image/webp", ".bmp": "image/bmp" } content_type = content_types.get(extension, "image/jpeg") 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()