با استفاده از کلیدهای منبع به فایلهای Drive مشترک دسترسی پیدا کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
میتوانید فایلها و پوشههای Google Drive را با استفاده از رابط کاربری Drive یا از طریق Google Drive API با دیگران به اشتراک بگذارید. وقتی از Drive اشتراکگذاری میکنید، میتوانید کنترل کنید که آیا افراد میتوانند فایل را ویرایش، نظر بدهند یا فقط باز کنند.
یک کلید منبع به محافظت از فایل شما در برابر دسترسی ناخواسته کمک می کند. کلیدهای منبع یک پارامتر اضافی هستند که ارسال می شوند تا کاربران بتوانند به فایل های خاصی که با استفاده از یک پیوند به اشتراک گذاشته شده اند دسترسی داشته باشند. کاربرانی که قبلا فایل را مشاهده نکرده اند باید کلید منبع را برای دسترسی به آن ارائه دهند. کسانی که اخیراً فایل را مشاهده کرده اند یا دسترسی مستقیم دارند، برای دسترسی به فایل به کلید منبع نیاز ندارند.
یک فایل Drive که با یک پیوند به اشتراک گذاشته شده است را فقط کاربرانی میتوانند کشف کنند که میتوانند در نتیجه منبع permissionstype=user یا type=group به فایل دسترسی داشته باشند. درخواستهای کاربرانی که فقط با استفاده از مجوز type=domain یا type=anyone به این فایلهای به اشتراک گذاشته شده پیوند دسترسی دارند، ممکن است به یک کلید منبع نیاز داشته باشند.
Drive API کلید منبع فایل را در قسمت فقط خواندنی resourceKey منبع files برمی گرداند.
اگر فایل یک میانبر Drive باشد، کلید منبع برای هدف میانبر در قسمت shortcutDetails.targetResourceKey فقط خواندنی برگردانده می شود.
فیلدهای موجود در منبع files که نشانیهای اینترنتی را برمیگردانند، مانند exportLinks ، webContentLink ، و webViewLink ، همچنین شامل resourceKey میشوند. کلاینت هایی که با Drive UI ادغام می شوند نیز می توانند از resourceKeys در پارامتر state استفاده کنند. برای اطلاعات بیشتر، به دانلود و صادرات فایلها مراجعه کنید.
کلید منبع را روی درخواست تنظیم کنید
کلیدهای منبع برای هر فایلی که توسط درخواستها به Drive API ارجاع میشود، در هدر HTTP X-Goog-Drive-Resource-Keys تنظیم میشوند.
درخواستها به Drive API میتوانند یک یا چند کلید منبع را با هدر HTTP X-Goog-Drive-Resource-Keys مشخص کنند.
نحو
شناسه فایل و جفت کلید منبع با استفاده از جداکننده اسلش رو به جلو ( / ) روی هدر تنظیم می شوند. هدر با ترکیب تمام شناسه فایل و جفت کلید منبع با استفاده از جداکننده های کاما ( , ) ساخته می شود.
برای مثال، درخواستی برای انتقال فایل fileId1 از پوشه fileId2 به پوشه fileId3 در نظر بگیرید. فرض کنید کلیدهای منبع برای این سه فایل به ترتیب resourceKey1 ، resourceKey2 و resourceKey3 هستند. هدر ساخته شده از این مقادیر با استفاده از جداکننده های اسلش رو به جلو و کاما به صورت زیر است:
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Access link-shared Drive files using resource keys\n\nYou can share Google Drive files and folders with others using the [Drive UI](/workspace/drive/api/guides/about-apps) or through the [Google Drive API](/workspace/drive/api/guides/create-file). When you share from\nDrive, you can control whether people can edit, comment on, or\nonly open the file.\n\nA *resource key* helps protect your file from unintended access. Resource keys\nare an additional parameter that are passed so users can access certain files\nthat have been shared using a link. Users who haven't viewed the file before\nmust provide the resource key to gain access. Those who have recently viewed the\nfile, or have direct access, don't need the resource key to access the file.\n\nA Drive file that's shared with a link can only be discovered by\nusers that can access the file as a result of a `type=user` or `type=group`\n[`permissions`](/workspace/drive/api/reference/rest/v3/permissions) resource. Requests from users\nthat only have access to these link-shared files using a `type=domain` or\n`type=anyone` permission might require a resource key.\n\nFor more information about permissions, see [Share files, folders and drives](/workspace/drive/api/guides/manage-sharing). For a complete list of roles and the operations\npermitted by each, see [Roles \\& permissions](/workspace/drive/api/guides/ref-roles).\n\nRead the resource key from the file\n-----------------------------------\n\nThe Drive API returns a file's resource key on the read-only\n`resourceKey` field of the [`files`](/workspace/drive/api/reference/rest/v3/files) resource.\n\nIf the file is a [Drive shortcut](/workspace/drive/api/guides/shortcuts), the\nresource key for the shortcut target is returned on the read-only\n`shortcutDetails.targetResourceKey` field.\n\nFields in the [`files`](/workspace/drive/api/reference/rest/v3/files) resource that return URLs,\nsuch as `exportLinks`, `webContentLink`, and `webViewLink`, also include the\n`resourceKey`. Clients that integrate with the Drive UI can also\nuse `resourceKeys` within the [`state`](/workspace/drive/api/guides/enable-sdk#construct)\nparameter. For more information, see [Download and export\nfiles](/workspace/drive/api/guides/manage-downloads).\n\nSet the resource key on the request\n-----------------------------------\n\nResource keys for any files referenced by requests to the Drive API\nare set on the `X-Goog-Drive-Resource-Keys` HTTP header.\n\nRequests to the Drive API can specify one or more resource keys with\nthe `X-Goog-Drive-Resource-Keys` HTTP header.\n\n### Syntax\n\nA file ID and resource key pair are set on the header using a forward slash\n(`/`) separator. The header is built by combining all the file ID and resource\nkey pairs using comma (`,`) separators.\n\nFor example, consider a request to move file `fileId1` from folder `fileId2` to\nfolder `fileId3`. Assume the resource keys for these three files are\n`resourceKey1`, `resourceKey2`, and `resourceKey3`, respectively. The header\nbuilt from these values using a forward slash and comma separators is: \n\n X-Goog-Drive-Resource-Keys: fileId1/resourceKey1,fileId2/resourceKey2,fileId3/resourceKey3\n\n### Related topics\n\n- [Share files, folders and drives](/workspace/drive/api/guides/manage-sharing)\n- [Download and export files](/workspace/drive/api/guides/manage-downloads)\n- [Protect file content](/workspace/drive/api/guides/content-restrictions)\n- [Configure a Drive UI integration](/workspace/drive/api/guides/enable-sdk)"]]