ContinueUpload

continue_upload(public_api_client, uuid, file_path, file_name, artifact_type)
Expand source code
continue_upload(public_api_client, uuid, file_path, file_name, artifact_type):
"""
Description
-----------
To upload artifacts in chunks (greater than 10 MB),
chunk size is a constant having value ~ 8 MB.
Args
----
public_api_client: QDC api client object.
uuid: uuid of the initiated start upload request.
file_path: Local path of the artifact to be uploaded.
file_name: Name of the artifact to be uploaded.
artifact_type: Type of the artifact (TESTPACKAGE, TESTSCRIPT).
Returns
-------
uuid: uuid of the uploaded artifact.
None: In case of any failure.
Usages
------
file_path = "C:\\Temp\\test.apk"
file_name = get_filename(file_path)
artifact_type = ArtifactType.TESTPACKAGE
uuid = start_upload(public_api_client, file_name, artifact_type)
continue_upload(public_api_client, uuid, file_path, file_name, artifact_type)
"""
parts = 1
offset = 0
with open(file_path, 'rb') as file:
while True:
chunk_data = file.read(CHUNK_SIZE)
if not chunk_data:
break
print(f"uploading file:{file_name}, type:{artifact_type}, part:{parts}, size:{CHUNK_SIZE}, offset:{offset}")
artifact_continue_upload_response = post_artifacts_uuid_continueupload.sync_detailed(
uuid=uuid,
body=PostArtifactsUploadBody(file=File(chunk_data, file_name)),
client=public_api_client,
offset=offset,
part=parts,
size=CHUNK_SIZE)
offset = offset + CHUNK_SIZE
parts = parts + 1
if artifact_continue_upload_response.status_code == 200:
print(f"start upload response: {artifact_continue_upload_response.content.decode('utf-8')}")
else:
print(
f"upload artifact failed with error code {artifact_continue_upload_response.status_code} {artifact_continue_upload_response.content.decode('utf-8')}")
return False
return True
Description
To upload artifacts in chunks (greater than 10 MB),
chunk size is a constant having value ~ 8 MB.
Arguments
public_api_client: QDC api client object.
uuid: uuid of the initiated start upload request.
file_path: Local path of the artifact to be uploaded.
file_name: Name of the artifact to be uploaded.
artifact_type: Type of the artifact (TESTPACKAGE, TESTSCRIPT).
Returns
uuid: uuid of the uploaded artifact.
None: In case of any failure.
Usages
file_path = "C:\\Temp\\test.apk"
file_name = get_filename(file_path)
artifact_type = ArtifactType.TESTPACKAGE
uuid = start_upload(public_api_client, file_name, artifact_type)
continue_upload(public_api_client, uuid, file_path, file_name, artifact_type)