ডাউনলোড করুন এবং ফাইল রপ্তানি করুন

গুগল ড্রাইভ এপিআই বিভিন্ন ধরণের ডাউনলোড এবং এক্সপোর্ট অ্যাকশন সমর্থন করে, যা নিম্নলিখিত টেবিলে তালিকাভুক্ত করা হয়েছে:

ডাউনলোড অ্যাকশন
alt=media URL প্যারামিটার ব্যবহার করে files.get পদ্ধতি ব্যবহার করে ব্লব ফাইলের কন্টেন্ট তৈরি করুন।
alt=media URL প্যারামিটার ব্যবহার করে revisions.get পদ্ধতি ব্যবহার করে পূর্ববর্তী সংস্করণে ব্লব ফাইলের বিষয়বস্তু।
webContentLink ফিল্ড ব্যবহার করে ব্রাউজারে ব্লব ফাইলের কন্টেন্ট।
দীর্ঘ সময় ধরে চলমান অপারেশনের সময় files.download পদ্ধতি ব্যবহার করে ফাইলের কন্টেন্ট ব্লব করুন। এটিই Google Vids ফাইল ডাউনলোড করার একমাত্র উপায়।
এক্সপোর্ট অ্যাকশন
files.export পদ্ধতি ব্যবহার করে, আপনার অ্যাপ যে ফর্ম্যাটে কাজ করতে পারে, সেই ফর্ম্যাটে Google Workspace-এর কন্টেন্ট ডকুমেন্ট করুন।
exportLinks ফিল্ড ব্যবহার করে ব্রাউজারে Google Workspace ডকুমেন্ট কন্টেন্ট।
exportLinks ফিল্ড ব্যবহার করে ব্রাউজারে পূর্ববর্তী সংস্করণে Google Workspace ডকুমেন্ট কন্টেন্ট।
দীর্ঘমেয়াদী অপারেশনের সময় files.download পদ্ধতি ব্যবহার করে Google Workspace ডকুমেন্ট কন্টেন্ট।

ফাইলের কন্টেন্ট ডাউনলোড বা এক্সপোর্ট করার আগে, ব্যবহারকারীরা files রিসোর্সে capabilities.canDownload ফিল্ড ব্যবহার করে ফাইলটি ডাউনলোড করতে পারছেন কিনা তা যাচাই করুন।

এখানে উল্লেখিত ফাইলের ধরণগুলির বিবরণের জন্য, blob এবং Google Workspace ফাইল সহ, ফাইলের ধরণ দেখুন।

এই নির্দেশিকার বাকি অংশে এই ধরণের ডাউনলোড এবং রপ্তানি ক্রিয়া সম্পাদনের জন্য বিস্তারিত নির্দেশাবলী রয়েছে।

ব্লব ফাইলের কন্টেন্ট ডাউনলোড করুন

ড্রাইভে সংরক্ষিত একটি ব্লব ফাইল ডাউনলোড করতে, ডাউনলোড করার জন্য ফাইলটির আইডি এবং alt=media URL প্যারামিটার সহ files.get পদ্ধতি ব্যবহার করুন। alt=media URL প্যারামিটার সার্ভারকে বলে যে বিকল্প প্রতিক্রিয়া ফর্ম্যাট হিসাবে কন্টেন্ট ডাউনলোডের অনুরোধ করা হচ্ছে।

alt=media URL প্যারামিটার হল একটি সিস্টেম প্যারামিটার যা সমস্ত Google REST API তে উপলব্ধ। আপনি যদি ড্রাইভ API এর জন্য একটি ক্লায়েন্ট লাইব্রেরি ব্যবহার করেন, তাহলে আপনাকে এই প্যারামিটারটি স্পষ্টভাবে সেট করার প্রয়োজন নেই।

নিম্নলিখিত কোড নমুনাটি দেখায় যে কীভাবে ড্রাইভ API ক্লায়েন্ট লাইব্রেরি সহ একটি ফাইল ডাউনলোড করতে files.get পদ্ধতি ব্যবহার করতে হয়।

জাভা

ড্রাইভ/স্নিপেটস/ড্রাইভ_ভি৩/এসআরসি/মেইন/জাভা/ডাউনলোডফাইল.জাভা
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;

/* Class to demonstrate use-case of drive's download file. */
public class DownloadFile {

  /**
   * Download a Document file in PDF format.
   *
   * @param realFileId file ID of any workspace document format file.
   * @return byte array stream if successful, {@code null} otherwise.
   * @throws IOException if service account credentials file not found.
   */
  public static ByteArrayOutputStream downloadFile(String realFileId) throws IOException {
        /* Load pre-authorized user credentials from the environment.
           TODO(developer) - See https://developers.google.com/identity for
          guides on implementing OAuth2 for your application.*/
    GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
        .createScoped(Arrays.asList(DriveScopes.DRIVE_FILE));
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(
        credentials);

    // Build a new authorized API client service.
    Drive service = new Drive.Builder(new NetHttpTransport(),
        GsonFactory.getDefaultInstance(),
        requestInitializer)
        .setApplicationName("Drive samples")
        .build();

    try {
      OutputStream outputStream = new ByteArrayOutputStream();

      service.files().get(realFileId)
          .executeMediaAndDownloadTo(outputStream);

      return (ByteArrayOutputStream) outputStream;
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      System.err.println("Unable to move file: " + e.getDetails());
      throw e;
    }
  }
}

পাইথন

ড্রাইভ/স্নিপেট/ড্রাইভ-ভি৩/ফাইল_স্নিপেট/ডাউনলোড_ফাইল.পি
import io

import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from googleapiclient.http import MediaIoBaseDownload


def download_file(real_file_id):
  """Downloads a file
  Args:
      real_file_id: ID of the file to download
  Returns : IO object with location.

  Load pre-authorized user credentials from the environment.
  TODO(developer) - See https://developers.google.com/identity
  for guides on implementing OAuth2 for the application.
  """
  creds, _ = google.auth.default()

  try:
    # create drive api client
    service = build("drive", "v3", credentials=creds)

    file_id = real_file_id

    # pylint: disable=maybe-no-member
    request = service.files().get_media(fileId=file_id)
    file = io.BytesIO()
    downloader = MediaIoBaseDownload(file, request)
    done = False
    while done is False:
      status, done = downloader.next_chunk()
      print(f"Download {int(status.progress() * 100)}.")

  except HttpError as error:
    print(f"An error occurred: {error}")
    file = None

  return file.getvalue()


if __name__ == "__main__":
  download_file(real_file_id="1KuPmvGq8yoYgbfW74OENMCB5H0n_2Jm9")

নোড.জেএস

ড্রাইভ/স্নিপেটস/ড্রাইভ_ভি৩/ফাইল_স্নিপেটস/ডাউনলোড_ফাইল.জেএস
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';

/**
 * Downloads a file from Google Drive.
 * @param {string} fileId The ID of the file to download.
 * @return {Promise<number>} The status of the download.
 */
async function downloadFile(fileId) {
  // Authenticate with Google and get an authorized client.
  // TODO (developer): Use an appropriate auth mechanism for your app.
  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/drive',
  });

  // Create a new Drive API client (v3).
  const service = google.drive({version: 'v3', auth});

  // Download the file.
  const file = await service.files.get({
    fileId,
    alt: 'media',
  });

  // Print the status of the download.
  console.log(file.status);
  return file.status;
}

পিএইচপি

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/এসআরসি/ড্রাইভডাউনলোডফাইল.পিএইচপি
<?php
use Google\Client;
use Google\Service\Drive;
function downloadFile()
 {
    try {

      $client = new Client();
      $client->useApplicationDefaultCredentials();
      $client->addScope(Drive::DRIVE);
      $driveService = new Drive($client);
      $realFileId = readline("Enter File Id: ");
      $fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
      $fileId = $realFileId;
      $response = $driveService->files->get($fileId, array(
          'alt' => 'media'));
      $content = $response->getBody()->getContents();
      return $content;

    } catch(Exception $e) {
      echo "Error Message: ".$e;
    }

}

.নেট

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/ড্রাইভভি৩স্নিপেট/ডাউনলোডফাইল.সিএস
using Google.Apis.Auth.OAuth2;
using Google.Apis.Download;
using Google.Apis.Drive.v3;
using Google.Apis.Services;

namespace DriveV3Snippets
{
    // Class to demonstrate use-case of drive's download file.
    public class DownloadFile
    {
        /// <summary>
        /// Download a Document file in PDF format.
        /// </summary>
        /// <param name="fileId">file ID of any workspace document format file.</param>
        /// <returns>byte array stream if successful, null otherwise.</returns>
        public static MemoryStream DriveDownloadFile(string fileId)
        {
            try
            {
                /* Load pre-authorized user credentials from the environment.
                 TODO(developer) - See https://developers.google.com/identity for 
                 guides on implementing OAuth2 for your application. */
                GoogleCredential credential = GoogleCredential
                    .GetApplicationDefault()
                    .CreateScoped(DriveService.Scope.Drive);

                // Create Drive API service.
                var service = new DriveService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "Drive API Snippets"
                });

                var request = service.Files.Get(fileId);
                var stream = new MemoryStream();

                // Add a handler which will be notified on progress changes.
                // It will notify on each chunk download and when the
                // download is completed or failed.
                request.MediaDownloader.ProgressChanged +=
                    progress =>
                    {
                        switch (progress.Status)
                        {
                            case DownloadStatus.Downloading:
                            {
                                Console.WriteLine(progress.BytesDownloaded);
                                break;
                            }
                            case DownloadStatus.Completed:
                            {
                                Console.WriteLine("Download complete.");
                                break;
                            }
                            case DownloadStatus.Failed:
                            {
                                Console.WriteLine("Download failed.");
                                break;
                            }
                        }
                    };
                request.Download(stream);

                return stream;
            }
            catch (Exception e)
            {
                // TODO(developer) - handle error appropriately
                if (e is AggregateException)
                {
                    Console.WriteLine("Credential Not found");
                }
                else
                {
                    throw;
                }
            }
            return null;
        }
    }
}

এই কোড নমুনাটি একটি লাইব্রেরি পদ্ধতি ব্যবহার করে যা অন্তর্নিহিত HTTP অনুরোধে alt=media URL প্যারামিটার যোগ করে।

আপনার অ্যাপ থেকে শুরু হওয়া ফাইল ডাউনলোডগুলি এমন একটি স্কোপের সাথে অনুমোদিত হতে হবে যা ফাইলের কন্টেন্টে পড়ার অ্যাক্সেস দেয়। উদাহরণস্বরূপ, drive.readonly.metadata স্কোপ ব্যবহার করে এমন একটি অ্যাপ ফাইলের কন্টেন্ট ডাউনলোড করার জন্য অনুমোদিত নয়। এই কোড নমুনাটি সীমাবদ্ধ "ড্রাইভ" ফাইল স্কোপ ব্যবহার করে যা ব্যবহারকারীদের আপনার সমস্ত ড্রাইভ ফাইল দেখতে এবং পরিচালনা করতে দেয়। ড্রাইভ স্কোপ সম্পর্কে আরও জানতে, Google Drive API স্কোপগুলি নির্বাচন করুন দেখুন।

owner অনুমতি (আমার ড্রাইভ ফাইলের জন্য) অথবা organizer অনুমতি (শেয়ার্ড ড্রাইভ ফাইলের জন্য) ব্যবহারকারীরা DownloadRestrictionsMetadata অবজেক্টের মাধ্যমে ডাউনলোড সীমাবদ্ধ করতে পারেন। আরও তথ্যের জন্য, ব্যবহারকারীদের আপনার ফাইল ডাউনলোড, মুদ্রণ বা অনুলিপি করা থেকে বিরত রাখুন দেখুন।

অপব্যবহারকারী হিসেবে চিহ্নিত ফাইলগুলি (যেমন ক্ষতিকারক সফ্টওয়্যার) শুধুমাত্র ফাইলের মালিক দ্বারা ডাউনলোড করা যাবে। অতিরিক্তভাবে, ব্যবহারকারী সম্ভাব্য অবাঞ্ছিত সফ্টওয়্যার বা অন্যান্য অপব্যবহারকারী ফাইল ডাউনলোড করার ঝুঁকি স্বীকার করেছেন তা নির্দেশ করার জন্য get query প্যারামিটার acknowledgeAbuse=true অন্তর্ভুক্ত করতে হবে। এই কোয়েরি প্যারামিটার ব্যবহার করার আগে আপনার অ্যাপ্লিকেশনটি ব্যবহারকারীকে ইন্টারেক্টিভভাবে সতর্ক করবে।

আংশিক ডাউনলোড

আংশিক ডাউনলোডের ক্ষেত্রে শুধুমাত্র একটি ফাইলের নির্দিষ্ট অংশ ডাউনলোড করা জড়িত। আপনি Range হেডারের সাহায্যে একটি বাইট রেঞ্জ ব্যবহার করে ফাইলের যে অংশটি ডাউনলোড করতে চান তা নির্দিষ্ট করতে পারেন। উদাহরণস্বরূপ:

Range: bytes=500-999

ব্লব ফাইলের কন্টেন্ট আগের ভার্সনে ডাউনলোড করুন

আপনি কেবল "Keep Forever" হিসেবে চিহ্নিত blob ফাইলের কন্টেন্ট রিভিশনগুলি ডাউনলোড করতে পারবেন। যদি আপনি একটি রিভিশন ডাউনলোড করতে চান, তাহলে প্রথমে এটি "Keep Forever" এ সেট করুন। আরও তথ্যের জন্য, "auto delete থেকে সংরক্ষণ করার জন্য রিভিশনগুলি নির্দিষ্ট করুন" দেখুন।

পূর্ববর্তী সংস্করণে ব্লব ফাইলের কন্টেন্ট ডাউনলোড করতে, ডাউনলোড করার জন্য ফাইলের আইডি, রিভিশনের আইডি এবং alt=media URL প্যারামিটার সহ revisions.get পদ্ধতি ব্যবহার করুন। alt=media URL প্যারামিটার সার্ভারকে বলে যে বিকল্প প্রতিক্রিয়া ফর্ম্যাট হিসাবে কন্টেন্ট ডাউনলোডের অনুরোধ করা হচ্ছে। files.get এর মতো, revisions.get পদ্ধতিটি ঐচ্ছিক ক্যোয়ারী প্যারামিটার acknowledgeAbuse এবং Range হেডারও গ্রহণ করে। আরও তথ্যের জন্য, দীর্ঘ-চলমান ক্রিয়াকলাপ পরিচালনা করুন দেখুন।

অনুরোধ প্রোটোকলটি এখানে দেখানো হয়েছে।

GET https://www.googleapis.com/drive/v3/files/{FILE_ID}/revisions/{REVISION_ID}?alt=media

ব্রাউজারে ব্লব ফাইলের কন্টেন্ট ডাউনলোড করুন

ড্রাইভে সংরক্ষিত ব্লব ফাইলের কন্টেন্ট API-এর পরিবর্তে ব্রাউজারের মধ্যে ডাউনলোড করতে, files রিসোর্সের webContentLink ফিল্ডটি ব্যবহার করুন। যদি ব্যবহারকারীর ফাইলটিতে ডাউনলোড অ্যাক্সেস থাকে, তাহলে ফাইল এবং এর কন্টেন্ট ডাউনলোড করার জন্য একটি লিঙ্ক ফেরত পাঠানো হবে। আপনি হয় একজন ব্যবহারকারীকে এই URL-এ পুনঃনির্দেশিত করতে পারেন, অথবা এটিকে ক্লিকযোগ্য লিঙ্ক হিসেবে অফার করতে পারেন।

দীর্ঘমেয়াদী অপারেশনের সময় ব্লব ফাইলের কন্টেন্ট ডাউনলোড করুন

দীর্ঘমেয়াদী অপারেশন চলাকালীন ব্লব ফাইলের কন্টেন্ট ডাউনলোড করতে, ডাউনলোড করার জন্য ফাইলের আইডি সহ files.download পদ্ধতি ব্যবহার করুন। আপনি ঐচ্ছিকভাবে রিভিশনের আইডি সেট করতে পারেন। এটিই Google Vids ফাইল ডাউনলোড করার একমাত্র উপায়। আরও তথ্যের জন্য, দীর্ঘমেয়াদী অপারেশন পরিচালনা করুন দেখুন।

Google Workspace ডকুমেন্ট কন্টেন্ট এক্সপোর্ট করুন

Google Workspace ডকুমেন্ট বাইট কন্টেন্ট এক্সপোর্ট করতে, এক্সপোর্ট করার জন্য ফাইলের আইডি এবং সঠিক MIME টাইপ সহ files.export পদ্ধতি ব্যবহার করুন। এক্সপোর্ট করা কন্টেন্ট 10 MB এর মধ্যে সীমাবদ্ধ।

নিম্নলিখিত কোড নমুনাটি দেখায় যে কীভাবে files.export পদ্ধতি ব্যবহার করে Drive API ক্লায়েন্ট লাইব্রেরি ব্যবহার করে PDF ফর্ম্যাটে একটি Google Workspace ডকুমেন্ট রপ্তানি করতে হয়:

জাভা

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/এসআরসি/মেইন/জাভা/এক্সপোর্টপিডিএফ.জাভা
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;

/* Class to demonstrate use-case of drive's export pdf. */
public class ExportPdf {

  /**
   * Download a Document file in PDF format.
   *
   * @param realFileId file ID of any workspace document format file.
   * @return byte array stream if successful, {@code null} otherwise.
   * @throws IOException if service account credentials file not found.
   */
  public static ByteArrayOutputStream exportPdf(String realFileId) throws IOException {
    // Load pre-authorized user credentials from the environment.
    // TODO(developer) - See https://developers.google.com/identity for
    // guides on implementing OAuth2 for your application.
    GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()
        .createScoped(Arrays.asList(DriveScopes.DRIVE_FILE));
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(
        credentials);

    // Build a new authorized API client service.
    Drive service = new Drive.Builder(new NetHttpTransport(),
        GsonFactory.getDefaultInstance(),
        requestInitializer)
        .setApplicationName("Drive samples")
        .build();

    OutputStream outputStream = new ByteArrayOutputStream();
    try {
      service.files().export(realFileId, "application/pdf")
          .executeMediaAndDownloadTo(outputStream);

      return (ByteArrayOutputStream) outputStream;
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      System.err.println("Unable to export file: " + e.getDetails());
      throw e;
    }
  }
}

পাইথন

ড্রাইভ/স্নিপেট/ড্রাইভ-ভি৩/ফাইল_স্নিপেট/এক্সপোর্ট_পিডিএফ.পিআই
import io

import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from googleapiclient.http import MediaIoBaseDownload


def export_pdf(real_file_id):
  """Download a Document file in PDF format.
  Args:
      real_file_id : file ID of any workspace document format file
  Returns : IO object with location

  Load pre-authorized user credentials from the environment.
  TODO(developer) - See https://developers.google.com/identity
  for guides on implementing OAuth2 for the application.
  """
  creds, _ = google.auth.default()

  try:
    # create drive api client
    service = build("drive", "v3", credentials=creds)

    file_id = real_file_id

    # pylint: disable=maybe-no-member
    request = service.files().export_media(
        fileId=file_id, mimeType="application/pdf"
    )
    file = io.BytesIO()
    downloader = MediaIoBaseDownload(file, request)
    done = False
    while done is False:
      status, done = downloader.next_chunk()
      print(f"Download {int(status.progress() * 100)}.")

  except HttpError as error:
    print(f"An error occurred: {error}")
    file = None

  return file.getvalue()


if __name__ == "__main__":
  export_pdf(real_file_id="1zbp8wAyuImX91Jt9mI-CAX_1TqkBLDEDcr2WeXBbKUY")

নোড.জেএস

ড্রাইভ/স্নিপেটস/ড্রাইভ_ভি৩/ফাইল_স্নিপেটস/এক্সপোর্ট_পিডিএফ.জেএস
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';

/**
 * Exports a Google Doc as a PDF.
 * @param {string} fileId The ID of the file to export.
 * @return {Promise<number>} The status of the export request.
 */
async function exportPdf(fileId) {
  // Authenticate with Google and get an authorized client.
  // TODO (developer): Use an appropriate auth mechanism for your app.
  const auth = new GoogleAuth({
    scopes: 'https://www.googleapis.com/auth/drive',
  });

  // Create a new Drive API client (v3).
  const service = google.drive({version: 'v3', auth});

  // Export the file as a PDF.
  const result = await service.files.export({
    fileId,
    mimeType: 'application/pdf',
  });

  // Print the status of the export.
  console.log(result.status);
  return result.status;
}

পিএইচপি

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/এসআরসি/ড্রাইভএক্সপোর্টপিডিএফ.পিপি
<?php
use Google\Client;
use Google\Service\Drive;
function exportPdf()
{
    try {
        $client = new Client();
        $client->useApplicationDefaultCredentials();
        $client->addScope(Drive::DRIVE);
        $driveService = new Drive($client);
        $realFileId = readline("Enter File Id: ");
        $fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo';
        $fileId = $realFileId;
        $response = $driveService->files->export($fileId, 'application/pdf', array(
            'alt' => 'media'));
        $content = $response->getBody()->getContents();
        return $content;

    }  catch(Exception $e) {
         echo "Error Message: ".$e;
    }

}

.নেট

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/ড্রাইভভি৩স্নিপেট/এক্সপোর্টপিডিএফ.সিএস
using Google.Apis.Auth.OAuth2;
using Google.Apis.Download;
using Google.Apis.Drive.v3;
using Google.Apis.Services;

namespace DriveV3Snippets
{
    // Class to demonstrate use of Drive export pdf
    public class ExportPdf
    {
        /// <summary>
        /// Download a Document file in PDF format.
        /// </summary>
        /// <param name="fileId">Id of the file.</param>
        /// <returns>Byte array stream if successful, null otherwise</returns>
        public static MemoryStream DriveExportPdf(string fileId)
        {
            try
            {
                /* Load pre-authorized user credentials from the environment.
                 TODO(developer) - See https://developers.google.com/identity for 
                 guides on implementing OAuth2 for your application. */
                GoogleCredential credential = GoogleCredential.GetApplicationDefault()
                    .CreateScoped(DriveService.Scope.Drive);

                // Create Drive API service.
                var service = new DriveService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "Drive API Snippets"
                });

                var request = service.Files.Export(fileId, "application/pdf");
                var stream = new MemoryStream();
                // Add a handler which will be notified on progress changes.
                // It will notify on each chunk download and when the
                // download is completed or failed.
                request.MediaDownloader.ProgressChanged +=
                    progress =>
                    {
                        switch (progress.Status)
                        {
                            case DownloadStatus.Downloading:
                            {
                                Console.WriteLine(progress.BytesDownloaded);
                                break;
                            }
                            case DownloadStatus.Completed:
                            {
                                Console.WriteLine("Download complete.");
                                break;
                            }
                            case DownloadStatus.Failed:
                            {
                                Console.WriteLine("Download failed.");
                                break;
                            }
                        }
                    };
                request.Download(stream);
                return stream;
            }
            catch (Exception e)
            {
                // TODO(developer) - handle error appropriately
                if (e is AggregateException)
                {
                    Console.WriteLine("Credential Not found");
                }
                else
                {
                    throw;
                }
            }
            return null;
        }
    }
}

এই কোড নমুনাটি সীমাবদ্ধ drive স্কোপ ব্যবহার করে যা ব্যবহারকারীদের আপনার সমস্ত ড্রাইভ ফাইল দেখতে এবং পরিচালনা করতে দেয়। ড্রাইভ স্কোপ সম্পর্কে আরও জানতে, Google ড্রাইভ API স্কোপ নির্বাচন করুন দেখুন।

কোড নমুনাটি export MIME টাইপকে application/pdf হিসেবে ঘোষণা করে। প্রতিটি Google Workspace ডকুমেন্টের জন্য সমর্থিত সমস্ত export MIME টাইপের সম্পূর্ণ তালিকার জন্য, Google Workspace ডকুমেন্টের জন্য Export MIME টাইপ দেখুন।

ব্রাউজারে Google Workspace ডকুমেন্ট কন্টেন্ট এক্সপোর্ট করুন

ব্রাউজারের মধ্যে Google Workspace ডকুমেন্ট কন্টেন্ট এক্সপোর্ট করতে, files রিসোর্সের exportLinks ফিল্ডটি ব্যবহার করুন। ডকুমেন্টের ধরণের উপর নির্ভর করে, প্রতিটি MIME টাইপের জন্য ফাইল এবং এর কন্টেন্ট ডাউনলোড করার জন্য একটি লিঙ্ক ফেরত দেওয়া হয়। আপনি হয় একজন ব্যবহারকারীকে একটি URL-এ রিডাইরেক্ট করতে পারেন, অথবা এটিকে ক্লিকযোগ্য লিঙ্ক হিসেবে অফার করতে পারেন।

ব্রাউজারে Google Workspace ডকুমেন্ট কন্টেন্ট আগের ভার্সনে এক্সপোর্ট করুন

ব্রাউজারের মধ্যে পূর্ববর্তী ভার্সনে Google Workspace ডকুমেন্ট কন্টেন্ট এক্সপোর্ট করতে, ডাউনলোড revisions.get জন্য ফাইলের আইডি এবং রিভিশনের আইডি ব্যবহার করে একটি এক্সপোর্ট লিঙ্ক তৈরি করুন যেখান থেকে আপনি ডাউনলোড করতে পারবেন। যদি ব্যবহারকারীর ফাইলটিতে ডাউনলোড অ্যাক্সেস থাকে, তাহলে ফাইল এবং এর কন্টেন্ট ডাউনলোড করার জন্য একটি লিঙ্ক ফেরত পাঠানো হয়। আপনি হয় একজন ব্যবহারকারীকে এই URL-এ রিডাইরেক্ট করতে পারেন, অথবা এটিকে ক্লিকযোগ্য লিঙ্ক হিসেবে অফার করতে পারেন।

দীর্ঘমেয়াদী অপারেশনের সময় Google Workspace ডকুমেন্ট কন্টেন্ট এক্সপোর্ট করুন

দীর্ঘমেয়াদী ক্রিয়াকলাপের সময় Google Workspace ডকুমেন্ট সামগ্রী রপ্তানি করতে, ডাউনলোড করার জন্য ফাইলের আইডি এবং সংশোধনের আইডি সহ files.download পদ্ধতি ব্যবহার করুন। আরও তথ্যের জন্য, দীর্ঘমেয়াদী ক্রিয়াকলাপ পরিচালনা করুন দেখুন।

ফাইলগুলি কীভাবে ভাগ করা হবে তা সীমিত করুন