下载 SDF

操作成功完成且您提取了资源后 name,您现在可以下载 ZIP 文件了 包含生成的 SDF 的文件(使用 media.download) 方法。

以下示例说明了如何使用客户端库下载结果文件:

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)

PHP

// 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)。此文件包含两列 第一个包含无法在该结构中找不到的资源的 ID 第二个参数则包含被排除的原因。

系统会出于多种原因跳过资源,包括位于不受支持的 状态或类型不受支持。使用 最新版本的结构化数据文件