UploadFile
upload_file(public_api_client, file_path, artifact_type)
Expand source code
upload_file(public_api_client, file_path, artifact_type):"""Description-----------High level wrapper function to upload artifact.It checks to upload file in chunks or not based on the size.Args----public_api_client: QDC api client object.file_path: Local path 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------# qdc_api is the name of the moduleapk_file_to_upload = "C:\\Temp\\test.apk"apk_uuid = qdc_api.upload_file(public_api_client, apk_file_to_upload, ArtifactType.TESTPACKAGE)"""if check_file_exists(file_path):file_size = get_file_size(file_path)file_name = get_filename(file_path)public_api_client = get_client_with_headers_added(public_api_client)print(f"start uploading file:{file_name}, path:{file_path}, type:{artifact_type}, size:{file_size} bytes")if file_size < CHUNK_SIZE:uuid = single_upload(public_api_client, file_path, file_name, artifact_type)if uuid is not None:print(f"successfully uploaded file, uuid:{uuid}")return uuidelse:print(f"failed to upload file")else:print(f"starting chunk upload for large file")uuid = start_upload(public_api_client, file_name, artifact_type)if uuid is not None:print(f"successfully started chunk upload, uuid:{uuid}")if continue_upload(public_api_client, uuid, file_path, file_name, artifact_type):print("successfully uploaded all chunks")if end_upload(public_api_client, uuid):print("successfully ended chunks upload")return uuidelse:print("failed to end chunks upload")else:print("failed to upload chunk")else:print("failed to start chunk upload")else:print(f"file path does not exists {file_path}, exiting...")return None
Description
High level wrapper function to upload artifact. It checks to upload file in chunks or not based on the size.
Arguments
public_api_client
: QDC api client object.file_path
: Local path 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
- qdc_api is the name of the module
apk_file_to_upload = "C:\\Temp\\test.apk"apk_uuid = qdc_api.upload_file(public_api_client, apk_file_to_upload, ArtifactType.TESTPACKAGE)