Resource: File
The metadata for a file.
Some resource methods (such as files.update
) require a fileId
. Use the files.list
method to retrieve the ID for a file.
JSON representation |
---|
{ "kind": string, "driveId": string, "fileExtension": string, "copyRequiresWriterPermission": boolean, "md5Checksum": string, "contentHints": { "indexableText": string, "thumbnail": { "image": string, "mimeType": string } }, "writersCanShare": boolean, "viewedByMe": boolean, "mimeType": string, "exportLinks": { string: string, ... }, "parents": [ string ], "thumbnailLink": string, "iconLink": string, "shared": boolean, "lastModifyingUser": { object ( |
Fields | |
---|---|
kind |
Output only. Identifies what kind of resource this is. Value: the fixed string |
driveId |
Output only. ID of the shared drive the file resides in. Only populated for items in shared drives. |
fileExtension |
Output only. The final component of |
copyRequiresWriterPermission |
Whether the options to copy, print, or download this file, should be disabled for readers and commenters. |
md5Checksum |
Output only. The MD5 checksum for the content of the file. This is only applicable to files with binary content in Google Drive. |
contentHints |
Additional information about the content of the file. These fields are never populated in responses. |
contentHints.indexableText |
Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements. |
contentHints.thumbnail |
A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail. |
contentHints.thumbnail.image |
The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5). A base64-encoded string. |
contentHints.thumbnail.mimeType |
The MIME type of the thumbnail. |
writersCanShare |
Whether users with only |
viewedByMe |
Output only. Whether the file has been viewed by this user. |
mimeType |
The MIME type of the file. Google Drive attempts to automatically detect an appropriate value from uploaded content, if no value is provided. The value cannot be changed unless a new revision is uploaded. If a file is created with a Google Doc MIME type, the uploaded content is imported, if possible. The supported import formats are published in the About resource. |
exportLinks |
Output only. Links for exporting Docs Editors files to specific formats. An object containing a list of |
parents[] |
The ID of the parent folder containing the file. A file can only have one parent folder; specifying multiple parents isn't supported. If not specified as part of a create request, the file is placed directly in the user's My Drive folder. If not specified as part of a copy request, the file inherits any discoverable parent of the source file. files.update requests must use the |
thumbnailLink |
Output only. A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Not intended for direct usage on web applications due to Cross-Origin Resource Sharing (CORS) policies, consider using a proxy server. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in |
iconLink |
Output only. A static, unauthenticated link to the file's icon. |
shared |
Output only. Whether the file has been shared. Not populated for items in shared drives. |
lastModifyingUser |
Output only. The last user to modify the file. This field is only populated when the last modification was performed by a signed-in user. |
owners[] |
Output only. The owner of this file. Only certain legacy files may have more than one owner. This field isn't populated for items in shared drives. |
headRevisionId |
Output only. The ID of the file's head revision. This is currently only available for files with binary content in Google Drive. |
sharingUser |
Output only. The user who shared the file with the requesting user, if applicable. |
webViewLink |
Output only. A link for opening the file in a relevant Google editor or viewer in a browser. |
webContentLink |
Output only. A link for downloading the content of the file in a browser. This is only available for files with binary content in Google Drive. |
size |
Output only. Size in bytes of blobs and first party editor files. Won't be populated for files that have no size, like shortcuts and folders. |
viewersCanCopyContent |
Deprecated: Use |
permissions[] |
Output only. The full list of permissions for the file. This is only available if the requesting user can share the file. Not populated for items in shared drives. |
hasThumbnail |
Output only. Whether this file has a thumbnail. This does not indicate whether the requesting app has access to the thumbnail. To check access, look for the presence of the thumbnailLink field. |
spaces[] |
Output only. The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'. |
folderColorRgb |
The color for a folder or a shortcut to a folder as an RGB hex string. The supported colors are published in the If an unsupported color is specified, the closest color in the palette is used instead. |
id |
The ID of the file. |
name |
The name of the file. This is not necessarily unique within a folder. Note that for immutable items such as the top level folders of shared drives, My Drive root folder, and Application Data folder the name is constant. |
description |
A short description of the file. |
starred |
Whether the user has starred the file. |
trashed |
Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, and other users cannot see files in the owner's trash. |
explicitlyTrashed |
Output only. Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder. |
createdTime |
The time at which the file was created (RFC 3339 date-time). |
modifiedTime |
The last time the file was modified by anyone (RFC 3339 date-time). Note that setting |
modifiedByMeTime |
Output only. The last time the file was modified by the user (RFC 3339 date-time). |
viewedByMeTime |
The last time the file was viewed by the user (RFC 3339 date-time). |
sharedWithMeTime |
Output only. The time at which the file was shared with the user, if applicable (RFC 3339 date-time). |
quotaBytesUsed |
Output only. The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with |
version |
Output only. A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user. |
originalFilename |
The original filename of the uploaded content if available, or else the original value of the |
ownedByMe |
Output only. Whether the user owns the file. Not populated for items in shared drives. |
fullFileExtension |
Output only. The full file extension extracted from the This is automatically updated when the |
properties |
A collection of arbitrary key-value pairs which are visible to all apps. Entries with null values are cleared in update and copy requests. An object containing a list of |
appProperties |
A collection of arbitrary key-value pairs which are private to the requesting app. Entries with null values are cleared in update and copy requests. These properties can only be retrieved using an authenticated request. An authenticated request uses an access token obtained with an OAuth 2 client ID. You cannot use an API key to retrieve private properties. An object containing a list of |
isAppAuthorized |
Output only. Whether the file was created or opened by the requesting app. |
teamDriveId |
Deprecated: Output only. Use |
capabilities |
Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take. |
capabilities.canChangeViewersCanCopyContent |
Deprecated: Output only. |
capabilities.canMoveChildrenOutOfDrive |
Output only. Whether the current user can move children of this folder outside of the shared drive. This is false when the item is not a folder. Only populated for items in shared drives. |
capabilities.canReadDrive |
Output only. Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives. |
capabilities.canEdit |
Output only. Whether the current user can edit this file. Other factors may limit the type of changes a user can make to a file. For example, see |
capabilities.canCopy |
Output only. Whether the current user can copy this file. For an item in a shared drive, whether the current user can copy non-folder descendants of this item, or this item itself if it is not a folder. |
capabilities.canComment |
Output only. Whether the current user can comment on this file. |
capabilities.canAddChildren |
Output only. Whether the current user can add children to this folder. This is always false when the item is not a folder. |
capabilities.canDelete |
Output only. Whether the current user can delete this file. |
capabilities.canDownload |
Output only. Whether the current user can download this file. |
capabilities.canListChildren |
Output only. Whether the current user can list the children of this folder. This is always false when the item is not a folder. |
capabilities.canRemoveChildren |
Output only. Whether the current user can remove children from this folder. This is always false when the item is not a folder. For a folder in a shared drive, use |
capabilities.canRename |
Output only. Whether the current user can rename this file. |
capabilities.canTrash |
Output only. Whether the current user can move this file to trash. |
capabilities.canReadRevisions |
Output only. Whether the current user can read the revisions resource of this file. For a shared drive item, whether revisions of non-folder descendants of this item, or this item itself if it is not a folder, can be read. |
capabilities.canReadTeamDrive |
Deprecated: Output only. Use |
capabilities.canMoveTeamDriveItem |
Deprecated: Output only. Use |
capabilities.canChangeCopyRequiresWriterPermission |
Output only. Whether the current user can change the |
capabilities.canMoveItemIntoTeamDrive |
Deprecated: Output only. Use |
capabilities.canUntrash |
Output only. Whether the current user can restore this file from trash. |
capabilities.canModifyContent |
Output only. Whether the current user can modify the content of this file. |
capabilities.canMoveItemWithinTeamDrive |
Deprecated: Output only. Use |
capabilities.canMoveItemOutOfTeamDrive |
Deprecated: Output only. Use |
capabilities.canDeleteChildren |
Output only. Whether the current user can delete children of this folder. This is false when the item is not a folder. Only populated for items in shared drives. |
capabilities.canMoveChildrenOutOfTeamDrive |
Deprecated: Output only. Use |
capabilities.canMoveChildrenWithinTeamDrive |
Deprecated: Output only. Use |
capabilities.canTrashChildren |
Output only. Whether the current user can trash children of this folder. This is false when the item is not a folder. Only populated for items in shared drives. |
capabilities.canMoveItemOutOfDrive |
Output only. Whether the current user can move this item outside of this drive by changing its parent. Note that a request to change the parent of the item may still fail depending on the new parent that is being added. |
capabilities.canAddMyDriveParent |
Output only. Whether the current user can add a parent for the item without removing an existing parent in the same request. Not populated for shared drive files. |
capabilities.canRemoveMyDriveParent |
Output only. Whether the current user can remove a parent from the item without adding another parent in the same request. Not populated for shared drive files. |
capabilities.canMoveItemWithinDrive |
Output only. Whether the current user can move this item within this drive. Note that a request to change the parent of the item may still fail depending on the new parent that is being added and the parent that is being removed. |
capabilities.canShare |
Output only. Whether the current user can modify the sharing settings for this file. |
capabilities.canMoveChildrenWithinDrive |
Output only. Whether the current user can move children of this folder within this drive. This is false when the item is not a folder. Note that a request to move the child may still fail depending on the current user's access to the child and to the destination folder. |
capabilities.canModifyContentRestriction |
Deprecated: Output only. Use one of |
capabilities.canAddFolderFromAnotherDrive |
Output only. Whether the current user can add a folder from another drive (different shared drive or My Drive) to this folder. This is false when the item is not a folder. Only populated for items in shared drives. |
capabilities.canChangeSecurityUpdateEnabled |
Output only. Whether the current user can change the securityUpdateEnabled field on link share metadata. |
capabilities.canAcceptOwnership |
Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files. |
capabilities.canReadLabels |
Output only. Whether the current user can read the labels on the file. |
capabilities.canModifyLabels |
Output only. Whether the current user can modify the labels on the file. |
capabilities.canModifyEditorContentRestriction |
Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted. |
capabilities.canModifyOwnerContentRestriction |
Output only. Whether the current user can add or modify content restrictions which are owner restricted. |
capabilities.canRemoveContentRestriction |
Output only. Whether there is a content restriction on the file that can be removed by the current user. |
hasAugmentedPermissions |
Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives. |
trashingUser |
Output only. If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives. |
thumbnailVersion |
Output only. The thumbnail version for use in thumbnail cache invalidation. |
trashedTime |
Output only. The time that the item was trashed (RFC 3339 date-time). Only populated for items in shared drives. |
modifiedByMe |
Output only. Whether the file has been modified by this user. |
permissionIds[] |
Output only. files.list of permission IDs for users with access to this file. |
imageMediaMetadata |
Output only. Additional metadata about image media, if available. |
imageMediaMetadata.flashUsed |
Output only. Whether a flash was used to create the photo. |
imageMediaMetadata.meteringMode |
Output only. The metering mode used to create the photo. |
imageMediaMetadata.sensor |
Output only. The type of sensor used to create the photo. |
imageMediaMetadata.exposureMode |
Output only. The exposure mode used to create the photo. |
imageMediaMetadata.colorSpace |
Output only. The color space of the photo. |
imageMediaMetadata.whiteBalance |
Output only. The white balance mode used to create the photo. |
imageMediaMetadata.width |
Output only. The width of the image in pixels. |
imageMediaMetadata.height |
Output only. The height of the image in pixels. |
imageMediaMetadata.location |
Output only. Geographic location information stored in the image. |
imageMediaMetadata.location.latitude |
Output only. The latitude stored in the image. |
imageMediaMetadata.location.longitude |
Output only. The longitude stored in the image. |
imageMediaMetadata.location.altitude |
Output only. The altitude stored in the image. |
imageMediaMetadata.rotation |
Output only. The number of clockwise 90 degree rotations applied from the image's original orientation. |
imageMediaMetadata.time |
Output only. The date and time the photo was taken (EXIF DateTime). |
imageMediaMetadata.cameraMake |
Output only. The make of the camera used to create the photo. |
imageMediaMetadata.cameraModel |
Output only. The model of the camera used to create the photo. |
imageMediaMetadata.exposureTime |
Output only. The length of the exposure, in seconds. |
imageMediaMetadata.aperture |
Output only. The aperture used to create the photo (f-number). |
imageMediaMetadata.focalLength |
Output only. The focal length used to create the photo, in millimeters. |
imageMediaMetadata.isoSpeed |
Output only. The ISO speed used to create the photo. |
imageMediaMetadata.exposureBias |
Output only. The exposure bias of the photo (APEX value). |
imageMediaMetadata.maxApertureValue |
Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value). |
imageMediaMetadata.subjectDistance |
Output only. The distance to the subject of the photo, in meters. |
imageMediaMetadata.lens |
Output only. The lens used to create the photo. |
videoMediaMetadata |
Output only. Additional metadata about video media. This may not be available immediately upon upload. |
videoMediaMetadata.width |
Output only. The width of the video in pixels. |
videoMediaMetadata.height |
Output only. The height of the video in pixels. |
videoMediaMetadata.durationMillis |
Output only. The duration of the video in milliseconds. |
shortcutDetails |
Shortcut file details. Only populated for shortcut files, which have the mimeType field set to |
shortcutDetails.targetId |
The ID of the file that this shortcut points to. Can only be set on |
shortcutDetails.targetMimeType |
Output only. The MIME type of the file that this shortcut points to. The value of this field is a snapshot of the target's MIME type, captured when the shortcut is created. |
shortcutDetails.targetResourceKey |
Output only. The ResourceKey for the target file. |
contentRestrictions[] |
Restrictions for accessing the content of the file. Only populated if such a restriction exists. |
resourceKey |
Output only. A key needed to access the item via a shared link. |
linkShareMetadata |
Output only. LinkShare related details. Contains details about the link URLs that clients are using to refer to this item. |
linkShareMetadata.securityUpdateEligible |
Output only. Whether the file is eligible for security update. |
linkShareMetadata.securityUpdateEnabled |
Output only. Whether the security update is enabled for this file. |
labelInfo |
Output only. An overview of the labels on the file. |
labelInfo.labels[] |
Output only. The set of labels on the file as requested by the label IDs in the |
sha1Checksum |
Output only. The SHA1 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. |
sha256Checksum |
Output only. The SHA256 checksum associated with this file, if available. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files. |
ContentRestriction
A restriction for accessing the content of the file.
JSON representation |
---|
{
"readOnly": boolean,
"reason": string,
"type": string,
"restrictingUser": {
object ( |
Fields | |
---|---|
readOnly |
Whether the content of the file is read-only. If a file is read-only, a new revision of the file may not be added, comments may not be added or modified, and the title of the file may not be modified. |
reason |
Reason for why the content of the file is restricted. This is only mutable on requests that also set |
type |
Output only. The type of the content restriction. Currently the only possible value is |
restrictingUser |
Output only. The user who set the content restriction. Only populated if |
restrictionTime |
Output only. The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if |
ownerRestricted |
Whether the content restriction can only be modified or removed by a user who owns the file. For files in shared drives, any user with |
systemRestricted |
Output only. Whether the content restriction was applied by the system, for example due to an esignature. Users cannot modify or remove system restricted content restrictions. |
Methods |
|
---|---|
|
Creates a copy of a file and applies any requested updates with patch semantics. |
|
Creates a new file. |
|
Permanently deletes a file owned by the user without moving it to the trash. |
|
Downloads content of a file. |
|
Permanently deletes all of the user's trashed files. |
|
Exports a Google Workspace document to the requested MIME type and returns exported byte content. |
|
Generates a set of file IDs which can be provided in create or copy requests. |
|
Gets a file's metadata or content by ID. |
|
Lists the user's files. |
|
Lists the labels on a file. |
|
Modifies the set of labels applied to a file. |
|
Updates a file's metadata and/or content. |
|
Subscribes to changes to a file. |