Spaces:
Running
Running
import requests | |
import fn | |
def upload(img_path, member): | |
member = fn.transform_number(member) | |
url = "https://api.cosmo.fans/rekord/v1/post/" | |
headers = { | |
"accept": "application/json, text/plain, */*", | |
"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNzE2MTQyMTU0LCJleHAiOjE3MTY3NDY5NTQsInN1YiI6IjE0MzMxMCJ9.cO2BTL-p4glxxpH84Kb2vFc3xTiJHBJql_ZNDyBMXlg", | |
"appversion": "2.7.8", | |
"accept-language": "ko-KR,ko;q=0.9", | |
"accept-encoding": "gzip, deflate, br", | |
"x-request-id": "246cc82d-889a-461a-a6ea-74bda45fdf72", | |
"deviceid": "iPad12,1", | |
"user-agent": "cosmo/78 CFNetwork/1494.0.7 Darwin/23.4.0", | |
} | |
# Multipart form data | |
data = { | |
"artistMemberIds": member, | |
"tagId": "4" | |
} | |
files = { | |
"file": ("6F98DCF5-060A-449E-BBE0-F4A3ECD80C77.png", open(img_path, "rb"), "image/png"), | |
} | |
response = requests.post(url, headers=headers, data=data, files=files) | |
return f"{response.status_code}\n{response.text}" | |