SDF 다운로드

작업이 성공적으로 완료되고 완료된 작업 응답에서 리소스 이름을 추출했으면 media.download 메서드를 사용하여 생성된 SDF가 포함된 zip 파일을 다운로드할 수 있습니다.

다음은 클라이언트 라이브러리를 사용하여 결과 파일을 다운로드하는 방법의 예입니다.

Java

// Extract download file resource name to use in download request
String downloadResourceName = operationResponse.getResponse()
    .get("resourceName").toString();

// Configure the Media.download request
Media.Download downloadRequest =
   service
       .media()
       .download(downloadResourceName);

// Create output stream for downloaded file
FileOutputStream outStream =
   new FileOutputStream(output-file);

// Download file
downloadRequest.executeMediaAndDownloadTo(outStream);

System.out.printf("File downloaded to %s\n", outputFile);

Python

# Extract download file resource name to use in download request
resourceName = operation["response"]["resourceName"]

# Configure the Media.download request
downloadRequest = service.media().download_media(resourceName=resourceName)

# Create output stream for downloaded file
outStream = io.FileIO(output-file, mode='wb')

# Make downloader object
downloader = googleHttp.MediaIoBaseDownload(outStream, downloadRequest)

# Download media file in chunks until finished
download_finished = False
while download_finished is False:
  _, download_finished = downloader.next_chunk()

print("File downloaded to %s" % output-file)

2,399필리핀

// Get client and set defer so it doesn't immediately return.
$client = $this->service->getClient();
$client->setDefer(true);

// Build media download request.
$request = $this->service->media->download(
    $operation->getResponse()['resourceName'],
    array('alt' => 'media')
);

// Call the API, getting the generated SDF.
$response = $client->execute($request);
$responseBody = $response->getBody();

// Writes the downloaded file. If the file already exists, it is
// overwritten.
file_put_contents(output-file, $responseBody);
$client->setDefer(false);

printf('File saved to: %s\n', output-file);

파일을 다운로드하고 압축을 풀면 생성된 구조화된 데이터 파일을 사용할 수 있습니다. 생성된 파일에는 SDF 파일 형식을 식별하는 일반적인 이름이 포함됩니다 (예: SDF-LineItems.csv).

건너뛰는 파일

요청된 리소스의 데이터를 상응하는 구조화된 데이터 파일에 포함할 수 없는 경우 다운로드한 ZIP 파일에는 '건너뛴' 파일(예: SDF-LineItems-Skipped.csv)이 포함되어 있을 수 있습니다. 이 파일은 2열 구조로 되어 있으며, 첫 번째에는 포함할 수 없는 리소스의 ID가 포함되고 두 번째 열에는 포함할 수 없는 리소스의 ID가 포함됩니다.

지원되지 않는 상태이거나 지원되지 않는 유형인 경우 등 여러 가지 이유로 리소스를 건너뛸 수 있습니다. 최신 버전의 SDF를 사용하여 리소스를 건너뛰지 않도록 하세요.