ডাউনলোড ফাইল

তৈরি করা স্ট্রাকচার্ড ডেটা ফাইল (SDF) একটি ZIP ফাইলে সংরক্ষিত থাকে। সফল Operation response.resourceName ফিল্ডে থাকা মান ব্যবহার করে media.download এর মাধ্যমে এই ফাইলটি ডাউনলোড করুন।

যেভাবে একটি SDF ZIP ফাইল ডাউনলোড করবেন:

জাভা

// Provide the name of the finished sdfdownloadtask operation.
String operationName = operation-name;

// Provide the path for the output file.
String outputFile = output-file;

// Retrieve the resource location from the finished operation.
Operation operation = service.sdfdownloadtasks().operations().get(operationName).execute();
String fileLocation = operation.getResponse().get("resourceName").toString();

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

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

// Download file.
downloadRequest.executeMediaAndDownloadTo(outStream);
System.out.printf("File downloaded at %s", outputFile);

পাইথন

# Import the object used for media download.
from googleapiclient import http as googleHttp

# Provide the name of the successfully completed sdfdownloadtask operation.
operation_name = operation-name

# Provide the path for the output file.
output_path = output-path

# Retrieve the completed operation.
operation = (
    service.sdfdownloadtasks().operations().get(name=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}.")

পিএইচপি

// Provide the name of the finished sdfdownloadtask operation.
$operationName = operation-name;

// Provide the path for the output file.
$outputFile = output-file;

try {
    // Call the API, retrieving the SDF Download Task.
    $operation = $this->service->sdfdownloadtasks_operations->get(
        $operationName
    );

    $fileLocation = $operation->getResponse()['resourceName'];

    $client = $this->service->getClient();
    $client->setDefer(true);

    $request = $this->service->media->download(
        $fileLocation,
        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($outputFile, $responseBody);
    $client->setDefer(false);

} catch (\Exception $e) {
    $this->renderError($e);
    return;
}

printf('<p>File downloaded at %s</p>', $outputFile);

ফাইলগুলি বের করুন

ZIP ফাইল থেকে তৈরি করা SDF ফাইলগুলো এক্সট্র্যাক্ট করুন। SDF ফাইলগুলো তাদের ধরন শনাক্ত করার জন্য সাধারণ ফাইলের নাম ব্যবহার করে। একটি লাইন আইটেম SDF-এর নাম হলো SDF-LineItems.csv

ZIP ফাইলে প্রতিটি ফাইল টাইপের জন্য "Skipped" ফাইল অন্তর্ভুক্ত থাকতে পারে। "Skipped" ফাইলগুলো SDF-এ অন্তর্ভুক্ত নয় এমন রিসোর্সগুলোকে চিহ্নিত করে। এগুলোর নামের শেষে -Skipped সাফিক্স থাকে। এই ফাইলগুলোর একটি দুই-কলামের কাঠামো রয়েছে। প্রথম কলামটি বাদ দেওয়া রিসোর্সটিকে চিহ্নিত করে। দ্বিতীয় কলামটি সেগুলোর বাদ পড়ার কারণ ব্যাখ্যা করে।