Last active
November 24, 2020 13:29
-
-
Save Clpsplug/8e493d23c6178e9d20fdf0845521897c to your computer and use it in GitHub Desktop.
This is how I tried to upload the local build to UCB.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# perform_bad_gateway == True: how I first called the API and the server ended up crashing | |
# perform_bad_gateway == False: how I call it NOW and the server has no issue with it | |
from tusclient import client | |
upload_url = "https://build-artifact-api.cloud.unity3d.com/api/v1" + \ | |
"/projects/{0}/buildtargets/{1}/builds/{2}/artifacts/{3}/upload/{4}".format( | |
project_id, | |
"_local", | |
build_number, | |
artifact_name, | |
artifact_file_name | |
) | |
t_client = client.TusClient(upload_url) | |
t_client.set_headers({"Authorization": "Basic {0}".format(MY_API_KEY), "content-type": "application/offset+octet-stream"}) | |
if perform_bad_gateway: | |
# Notice that I set the chunk size to 200. I did this to see the progress. | |
# However, If this value is present, the server fail to complete the request. | |
uploader = t_client.uploader(file_stream=open("file/to/upload", "rb"), chunk_size=200) | |
else: | |
# If chunk_size is absent, then 64-bit maximum integer is used. | |
uploader = t_client.uploader(file_stream=open("file/to/upload", "rb")) | |
while uploader.file_size > uploader.offset: | |
uploader.upload_chunk() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment