הורדת ה-SDF

אחרי שהפעולה מסתיימת בהצלחה ומחלצים את שם המשאב מתשובת הפעולה שהושלמו, אפשר להוריד את קובץ ה-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 שהורדתם עשוי לכלול קובץ בשם 'Skipped' (דילוג) (לדוגמה: SDF-LineItems-Skipped.csv). לקובץ הזה תהיה מבנה של שתי עמודות, הראשונה תכלול את המזהים של המשאבים שלא ניתן היה לכלול והשנייה תכלול את הסיבה להחרגתם.

יכולות להיות הרבה סיבות לדילוג על משאבים, כולל מצב שלהם שלא נתמך או סוג שלהם שלא נתמך. כדי למנוע דילוג על משאבים, מומלץ להשתמש בגרסה העדכנית ביותר של SDF.