หลังจากประมวลผลไฟล์ Structured Data ที่อัปโหลดเรียบร้อยแล้ว ให้ดาวน์โหลด
ไฟล์ ZIP ที่ได้จากตำแหน่งทรัพยากรที่ระบุโดยใช้
media.download
วิธีดึงข้อมูลตำแหน่งไฟล์และดาวน์โหลดไฟล์ 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
อาจมีไฟล์ผลลัพธ์ต่อไปนี้อย่างใดอย่างหนึ่งหรือทั้ง 2 ไฟล์ โดย
{EntityName} เป็นประเภทของทรัพยากร เช่น LineItems
SDF-{EntityName}-Updated-ResultFile.csvซึ่งแสดงรายการทรัพยากรที่สร้างหรืออัปเดตสำเร็จแล้วSDF-{EntityName}-Failed-ResultFile.csvซึ่งแสดงรายการทรัพยากรที่อัปเดตหรือสร้างไม่สำเร็จ พร้อมข้อความแสดงข้อผิดพลาด