import requests
import sys
sys.path.append('./')
from build_script.params import *

file_path, file_name = sys.argv[1:]
# Replace with the key parameter from your robot's webhook URL # Specify the file type: file or voice, as needed
upload_url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key={qw_access_key}"

# file_path = "/Users/zgl/Desktop/sd/project/smdp-mp-application/buildPackage/release/smdp-1.0.6-12-sit-release.apk"  # Replace with the path to your file
# file_name = "smdp-1.0.6-12-sit-release.apk"  # Specify the file name for display

# Read file data
with open(file_path, "rb") as file:
    file_data = file.read()

# Construct the request payload
files = {"media": (file_name, file_data, "application/octet-stream")}

# Send the HTTP request
response = requests.post(upload_url, files=files)

# Parse the JSON response
response_data = response.json()

# Extract the media_id
media_id = response_data.get("media_id", "")

# Output the media_id
print(media_id)
