下载报告
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Display & Video 360 报告成功生成后,请从 Report
资源中的 Google Cloud Storage 路径下载生成的报告文件。
以下是从报告中检索路径并下载报告文件的方法:
Java
// The ID of the parent query.
Long queryId = query-id;
// The ID of the report to download.
Long reportId = report-id;
// The path to which to download the file.
String outputFilePath = output-file-path;
// Retrieve the report resource.
Report report =
service.queries().reports().get(queryId, reportId).execute();
// Download report file.
System.out.println("Downloading report file.");
DownloadUtils.downloadFileFromCloudStorage(
report.getMetadata().getGoogleCloudStoragePath(), outputFilePath);
System.out.printf(
"Report %s successfully downloaded at %s.%n",
report.getKey().getReportId(), outputFilePath);
Python
# The ID of the parent query.
query_id = query-id
# The ID of the relevant report resource.
report_id = report-id
# The path to which to download the file.
output_file_path = output-file-path
# Retrieve report.
report = service.queries().reports().get(
queryId=query_id,
reportId=report_id
).execute()
cloud_storage_path = report["metadata"]["googleCloudStoragePath"]
# Download file.
with open(output_file_path, "wb") as output:
with closing(urlopen(cloud_storage_path)) as url:
output.write(url.read())
print("Download complete.")
PHP
// The ID of the parent query.
$queryId = query-id;
// The ID of the report to download.
$reportId = report-id;
// The path to which to download the file.
$outputFilePath = output-file-path;
// Retrieve the report resource.
$report = $this->service->queries_reports->get($queryId, $reportId);
// Download the file.
file_put_contents(
$outputFilePath,
fopen($report->getMetadata()->getGoogleCloudStoragePath(), 'r')
);
printf(
'Report %s successfully downloaded at %s.<br>',
$reportId,
$outputFilePath
);
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eDisplay & Video 360 reports are stored in Google Cloud Storage after successful generation.\u003c/p\u003e\n"],["\u003cp\u003eYou can access the report file by retrieving its Google Cloud Storage path from the \u003ccode\u003eReport\u003c/code\u003e resource.\u003c/p\u003e\n"],["\u003cp\u003eCode samples demonstrate how to download the report file using the Google Cloud Storage path in Java, Python, and PHP.\u003c/p\u003e\n"]]],[],null,["# Download report\n\nAfter a Display \\& Video 360 report finishes generating successfully, download the\ngenerated report file from the [Google Cloud Storage path](//cloud.google.com/storage/docs) in the\n[`Report`](/bid-manager/reference/rest/current/queries.reports#Report) resource.\n\nHere's how to retrieve the path from the report and download the report file: \n\n### Java\n\n```java\n// The ID of the parent query.\nLong queryId = query-id;\n\n// The ID of the report to download.\nLong reportId = report-id;\n\n// The path to which to download the file.\nString outputFilePath = output-file-path;\n\n// Retrieve the report resource.\nReport report =\n service.queries().reports().get(queryId, reportId).execute();\n\n// Download report file.\nSystem.out.println(\"Downloading report file.\");\nDownloadUtils.downloadFileFromCloudStorage(\n report.getMetadata().getGoogleCloudStoragePath(), outputFilePath);\nSystem.out.printf(\n \"Report %s successfully downloaded at %s.%n\",\n report.getKey().getReportId(), outputFilePath);\n```\n\n### Python\n\n```python\n# The ID of the parent query.\nquery_id = query-id\n\n# The ID of the relevant report resource.\nreport_id = report-id\n\n# The path to which to download the file.\noutput_file_path = output-file-path\n\n# Retrieve report.\nreport = service.queries().reports().get(\n queryId=query_id,\n reportId=report_id\n).execute()\n\ncloud_storage_path = report[\"metadata\"][\"googleCloudStoragePath\"]\n\n# Download file.\nwith open(output_file_path, \"wb\") as output:\n with closing(urlopen(cloud_storage_path)) as url:\n output.write(url.read())\n print(\"Download complete.\")\n```\n\n### PHP\n\n```php\n// The ID of the parent query.\n$queryId = \u003cvar translate=\"no\"\u003equery-id\u003c/var\u003e;\n\n // The ID of the report to download.\n$reportId = \u003cvar translate=\"no\"\u003ereport-id\u003c/var\u003e;\n\n// The path to which to download the file.\n$outputFilePath = \u003cvar translate=\"no\"\u003eoutput-file-path\u003c/var\u003e;\n\n// Retrieve the report resource.\n$report = $this-\u003eservice-\u003equeries_reports-\u003eget($queryId, $reportId);\n\n// Download the file.\nfile_put_contents(\n $outputFilePath,\n fopen($report-\u003egetMetadata()-\u003egetGoogleCloudStoragePath(), 'r')\n);\n\nprintf(\n 'Report %s successfully downloaded at %s.\u003cbr\u003e',\n $reportId,\n $outputFilePath\n);\n```"]]