SingleUpload
single_upload(public_api_client, file_path, file_name, artifact_type)
Expand source code
single_upload(public_api_client, file_path, file_name, artifact_type):"""Description-----------To upload artifact smaller in one go (less than 10 MB).Args----public_api_client: QDC api client object.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.TESTPACKAGEuuid = single_upload(public_api_client, file_path, file_name, artifact_type)"""with open(file_path, 'rb') as file:while True:data = file.read()artifact_upload_response = post_artifacts_upload.sync_detailed(client=public_api_client,body=PostArtifactsUploadBody(file=File(data, file_name)),filename=file_name,artifact_type=artifact_type)if artifact_upload_response.status_code == 200:print(f"Upload response: {artifact_upload_response.content.decode('utf-8')}")return artifact_upload_response.parsed.uuidelse:print(f"Upload artifact failed with error code {artifact_upload_response.status_code} {artifact_upload_response.content.decode('utf-8')}")return None
Description
To upload artifact smaller in one go (less than 10 MB).
Arguments
public_api_client
: QDC api client object.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.TESTPACKAGEuuid = single_upload(public_api_client, file_path, file_name, artifact_type)