アップロードされた構造化データ ファイルが正常に処理されたら、media.download を使用して、指定されたリソースの場所から結果の ZIP ファイルをダウンロードします。
ファイルの場所を取得して ZIP ファイルをダウンロードする方法は次のとおりです。
# Import the object used for media download. from googleapiclient import http as googleHttp import io # Provide the name of the successfully completed sdfuploadtask operation. operation_name = operation-name # Provide the path for the output file. output_path = output-path # Retrieve the completed operation. operation = service.sdfuploadtasks().operations().get(operation_name).execute() # Retrieve the file location from the operation. file_location = operation["response"]["resourceName"] # Configure the media.download request. download_request = service.media().download_media(resourceName=file_location) # Create output stream for downloaded file. out_stream = io.FileIO(output_path, mode='wb') # Build downloader object. downloader = googleHttp.MediaIoBaseDownload(out_stream, download_request) # Download file in chunks until finished. download_finished = False while download_finished is False: _, download_finished = downloader.next_chunk() print(f'File downloaded at {output_path}.')
ファイルを抽出する
ダウンロードした ZIP ファイルを解凍して、SDF アップロードの結果を抽出します。次の結果ファイルが 1 つまたは両方存在する可能性があります。{EntityName} は、LineItems などのリソースのタイプです。
SDF-{EntityName}-Updated-ResultFile.csv: 作成または更新が成功したリソースのリストSDF-{EntityName}-Failed-ResultFile.csv: 更新または作成に失敗したリソースとエラー メッセージが一覧表示されます。