결과 다운로드

업로드된 구조화된 데이터 파일이 성공적으로 처리되면 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 업로드 결과를 추출합니다. 다음 결과 파일 중 하나 또는 둘 다가 있을 수 있으며, {EntityName}LineItems과 같은 리소스 유형입니다.

  • SDF-{EntityName}-Updated-ResultFile.csv: 성공적으로 생성되거나 업데이트된 리소스를 나열합니다.
  • SDF-{EntityName}-Failed-ResultFile.csv: 업데이트 또는 생성에 실패한 리소스와 오류 메시지를 나열합니다.