আপনার অ্যাপ দ্বারা সঞ্চিত সামগ্রীতে একটি শর্টকাট ফাইল তৈরি করুন৷

গুগল ড্রাইভের থার্ড-পার্টি শর্টকাটগুলি হল মেটাডেটা-শুধুমাত্র ফাইল যা বহিরাগত, থার্ড-পার্টি মালিকানাধীন, স্টোরেজ সিস্টেমের অন্যান্য ফাইলের সাথে লিঙ্ক করে। এই শর্টকাটগুলি ড্রাইভের বাইরের কোনও অ্যাপ্লিকেশন দ্বারা সাধারণত একটি ভিন্ন ডেটাস্টোর বা ক্লাউড স্টোরেজ সিস্টেমে সংরক্ষিত "কন্টেন্ট" ফাইলগুলির রেফারেন্স লিঙ্ক হিসাবে কাজ করে।

তৃতীয় পক্ষের শর্টকাট তৈরি করতে, Google Drive API এর files.create পদ্ধতি ব্যবহার করুন এবং MIME টাইপটি application/vnd.google-apps.drive-sdk এ সেট করুন। ফাইল তৈরি করার সময় কোনও কন্টেন্ট আপলোড করবেন না। আরও তথ্যের জন্য, Google Workspace এবং Google Drive সমর্থিত MIME টাইপগুলি দেখুন।

আপনি তৃতীয় পক্ষের শর্টকাট আপলোড বা ডাউনলোড করতে পারবেন না।

নিম্নলিখিত কোড নমুনাগুলি দেখায় কিভাবে একটি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে একটি তৃতীয় পক্ষের শর্টকাট তৈরি করতে হয়:

জাভা

ড্রাইভ/স্নিপেটস/ড্রাইভ_ভি৩/এসআরসি/মেইন/জাভা/ক্রিয়েটশর্টকাট.জাভা
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.api.services.drive.model.File;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Arrays;

/* Class to demonstrate Drive's create shortcut use-case */
public class CreateShortcut {

  /**
   * Creates shortcut for file.
   *
   * @throws IOException if service account credentials file not found.
   */
  public static String createShortcut() 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 {
      // Create Shortcut for file.
      File fileMetadata = new File();
      fileMetadata.setName("Project plan");
      fileMetadata.setMimeType("application/vnd.google-apps.drive-sdk");

      File file = service.files().create(fileMetadata)
          .setFields("id")
          .execute();
      System.out.println("File ID: " + file.getId());
      return file.getId();
    } catch (GoogleJsonResponseException e) {
      // TODO(developer) - handle error appropriately
      System.err.println("Unable to create shortcut: " + e.getDetails());
      throw e;
    }
  }
}

পাইথন

ড্রাইভ/স্নিপেটস/ড্রাইভ-ভি৩/ফাইল_স্নিপেট/ক্রিয়েট_শর্টকাট.পি
import google.auth
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError


def create_shortcut():
  """Create a third party shortcut

  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_metadata = {
        "name": "Project plan",
        "mimeType": "application/vnd.google-apps.drive-sdk",
    }

    # pylint: disable=maybe-no-member
    file = service.files().create(body=file_metadata, fields="id").execute()
    print(f'File ID: {file.get("id")}')

  except HttpError as error:
    print(f"An error occurred: {error}")
  return file.get("id")


if __name__ == "__main__":
  create_shortcut()

পিএইচপি

ড্রাইভ/স্নিপেট/ড্রাইভ_ভি৩/এসআরসি/ড্রাইভক্রিয়েটশর্টকাট.পিএইচপি
<?php
use Google\Client;
use Google\Service\Drive;
use Google\Service\Drive\DriveFile;
function createShortcut()
{
    try {

        $client = new Client();
        $client->useApplicationDefaultCredentials();
        $client->addScope(Drive::DRIVE);
        $driveService = new Drive($client);
        $fileMetadata = new DriveFile(array(
            'name' => 'Project plan',
            'mimeType' => 'application/vnd.google-apps.drive-sdk'));
        $file = $driveService->files->create($fileMetadata, array(
            'fields' => 'id'));
        printf("File ID: %s\n", $file->id);
        return $file->id;

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

}

.নেট

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

namespace DriveV3Snippets
{
    // Class to demonstrate Drive's create shortcut use-case
    public class CreateShortcut
    {
        /// <summary>
        /// Create a third party shortcut.
        /// </summary>
        /// <returns>newly created shortcut file id, null otherwise.</returns>
        public static string DriveCreateShortcut()
        {
            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"
                });

                // Create Shortcut for file.
                var fileMetadata = new Google.Apis.Drive.v3.Data.File()
                {
                    Name = "Project plan",
                    MimeType = "application/vnd.google-apps.drive-sdk"
                };
                var request = service.Files.Create(fileMetadata);
                request.Fields = "id";
                var file = request.Execute();
                // Prints the shortcut file id.
                Console.WriteLine("File ID: " + file.Id);
                return file.Id;
            }
            catch (Exception e)
            {
                // TODO(developer) - handle error appropriately
                if (e is AggregateException)
                {
                    Console.WriteLine("Credential Not found");
                }
                else
                {
                    throw;
                }
            }
            return null;
        }
    }
}

নোড.জেএস

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

/**
 * Creates a shortcut to a third-party resource.
 * @return {Promise<string|null|undefined>} The shortcut ID.
 */
async function createShortcut() {
  // 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});

  // The metadata for the new shortcut.
  const fileMetadata = {
    name: 'Project plan',
    mimeType: 'application/vnd.google-apps.drive-sdk',
  };

  // Create the new shortcut.
  const file = await service.files.create({
    requestBody: fileMetadata,
    fields: 'id',
  });

  // Print the ID of the new shortcut.
  console.log('File Id:', file.data.id);
  return file.data.id;
}

থার্ড-পার্টি শর্টকাট কীভাবে কাজ করে

যখন আপনি files.create পদ্ধতি ব্যবহার করে একটি তৃতীয় পক্ষের শর্টকাট তৈরি করেন, তখন এটি মেটাডেটা সন্নিবেশ করার জন্য একটি POST অনুরোধ ব্যবহার করে এবং আপনার অ্যাপের সামগ্রীতে একটি শর্টকাট তৈরি করে:

POST https://www.googleapis.com/drive/v3/files
Authorization: AUTHORIZATION_HEADER

{
  "title": "FILE_TITLE",
  "mimeType": "application/vnd.google-apps.drive-sdk"
}

যখন তৃতীয় পক্ষের শর্টকাটটি ক্লিক করা হয়, তখন ব্যবহারকারীকে সেই বহিরাগত সাইটে পুনঃনির্দেশিত করা হয় যেখানে ফাইলটি রাখা হয়। ড্রাইভ ফাইল আইডিটি state প্যারামিটারে থাকে। আরও তথ্যের জন্য, অ্যাপ-নির্দিষ্ট নথির জন্য একটি খোলা URL পরিচালনা করুন দেখুন।

তৃতীয় পক্ষের অ্যাপ বা ওয়েবসাইটটি তখন তাদের সিস্টেমের মধ্যে থাকা সামগ্রীর সাথে state প্যারামিটারে থাকা ফাইল আইডি মেলানোর জন্য দায়ী।

কাস্টম থাম্বনেইল এবং ইনডেক্সেবল টেক্সট যোগ করুন

তৃতীয় পক্ষের শর্টকাটের সাথে সম্পর্কিত ফাইলগুলির আবিষ্কারযোগ্যতা বাড়ানোর জন্য, আপনি ফাইল মেটাডেটা সন্নিবেশ বা পরিবর্তন করার সময় থাম্বনেইল ছবি এবং সূচীযোগ্য পাঠ্য উভয়ই আপলোড করতে পারেন। আরও তথ্যের জন্য, ফাইল মেটাডেটা পরিচালনা করুন দেখুন।