REST Resource: files

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,
  "userPermission": {
    object (Permission)
  },
  "fileExtension": string,
  "md5Checksum": string,
  "selfLink": string,
  "ownerNames": [
    string
  ],
  "lastModifyingUserName": string,
  "editable": boolean,
  "writersCanShare": boolean,
  "downloadUrl": string,
  "mimeType": string,
  "exportLinks": {
    string: string,
    ...
  },
  "driveId": string,
  "parents": [
    {
      object (ParentReference)
    }
  ],
  "thumbnailLink": string,
  "appDataContents": boolean,
  "webViewLink": string,
  "iconLink": string,
  "shared": boolean,
  "lastModifyingUser": {
    object (User)
  },
  "owners": [
    {
      object (User)
    }
  ],
  "openWithLinks": {
    string: string,
    ...
  },
  "defaultOpenWithLink": string,
  "headRevisionId": string,
  "properties": [
    {
      object (Property)
    }
  ],
  "copyable": boolean,
  "etag": string,
  "sharingUser": {
    object (User)
  },
  "alternateLink": string,
  "embedLink": string,
  "webContentLink": string,
  "fileSize": string,
  "copyRequiresWriterPermission": boolean,
  "permissions": [
    {
      object (Permission)
    }
  ],
  "hasThumbnail": boolean,
  "spaces": [
    string
  ],
  "folderColorRgb": string,
  "id": string,
  "title": string,
  "description": string,
  "labels": {
    "viewed": boolean,
    "restricted": boolean,
    "starred": boolean,
    "hidden": boolean,
    "trashed": boolean,
    "modified": boolean
  },
  "explicitlyTrashed": boolean,
  "createdDate": string,
  "modifiedDate": string,
  "modifiedByMeDate": string,
  "lastViewedByMeDate": string,
  "markedViewedByMeDate": string,
  "sharedWithMeDate": string,
  "quotaBytesUsed": string,
  "version": string,
  "indexableText": {
    "text": string
  },
  "originalFilename": string,
  "ownedByMe": boolean,
  "canComment": boolean,
  "shareable": boolean,
  "fullFileExtension": string,
  "isAppAuthorized": boolean,
  "teamDriveId": string,
  "capabilities": {
    "canChangeRestrictedDownload": boolean,
    "canMoveChildrenOutOfDrive": boolean,
    "canReadDrive": boolean,
    "canEdit": boolean,
    "canCopy": boolean,
    "canComment": boolean,
    "canAddChildren": boolean,
    "canDelete": boolean,
    "canDownload": boolean,
    "canListChildren": boolean,
    "canRemoveChildren": boolean,
    "canRename": boolean,
    "canTrash": boolean,
    "canReadRevisions": boolean,
    "canReadTeamDrive": boolean,
    "canMoveTeamDriveItem": boolean,
    "canChangeCopyRequiresWriterPermission": boolean,
    "canMoveItemIntoTeamDrive": boolean,
    "canUntrash": boolean,
    "canModifyContent": boolean,
    "canMoveItemWithinTeamDrive": boolean,
    "canMoveItemOutOfTeamDrive": boolean,
    "canDeleteChildren": boolean,
    "canMoveChildrenOutOfTeamDrive": boolean,
    "canMoveChildrenWithinTeamDrive": boolean,
    "canTrashChildren": boolean,
    "canMoveItemOutOfDrive": boolean,
    "canAddMyDriveParent": boolean,
    "canRemoveMyDriveParent": boolean,
    "canMoveItemWithinDrive": boolean,
    "canShare": boolean,
    "canMoveChildrenWithinDrive": boolean,
    "canModifyContentRestriction": boolean,
    "canAddFolderFromAnotherDrive": boolean,
    "canChangeSecurityUpdateEnabled": boolean,
    "canAcceptOwnership": boolean,
    "canReadLabels": boolean,
    "canModifyLabels": boolean,
    "canModifyEditorContentRestriction": boolean,
    "canModifyOwnerContentRestriction": boolean,
    "canRemoveContentRestriction": boolean
  },
  "hasAugmentedPermissions": boolean,
  "trashingUser": {
    object (User)
  },
  "canReadRevisions": boolean,
  "thumbnailVersion": string,
  "trashedDate": string,
  "permissionIds": [
    string
  ],
  "thumbnail": {
    "image": string,
    "mimeType": string
  },
  "imageMediaMetadata": {
    "flashUsed": boolean,
    "meteringMode": string,
    "sensor": string,
    "exposureMode": string,
    "colorSpace": string,
    "whiteBalance": string,
    "width": integer,
    "height": integer,
    "location": {
      "latitude": number,
      "longitude": number,
      "altitude": number
    },
    "rotation": integer,
    "date": string,
    "cameraMake": string,
    "cameraModel": string,
    "exposureTime": number,
    "aperture": number,
    "focalLength": number,
    "isoSpeed": integer,
    "exposureBias": number,
    "maxApertureValue": number,
    "subjectDistance": integer,
    "lens": string
  },
  "videoMediaMetadata": {
    "width": integer,
    "height": integer,
    "durationMillis": string
  },
  "shortcutDetails": {
    "targetId": string,
    "targetMimeType": string,
    "targetResourceKey": string
  },
  "contentRestrictions": [
    {
      object (ContentRestriction)
    }
  ],
  "resourceKey": string,
  "linkShareMetadata": {
    "securityUpdateEligible": boolean,
    "securityUpdateEnabled": boolean
  },
  "labelInfo": {
    "labels": [
      {
        object (Label)
      }
    ]
  },
  "sha1Checksum": string,
  "sha256Checksum": string
}
Fields
kind

string

Output only. The type of file. This is always drive#file.

userPermission

object (Permission)

Output only. The permissions for the authenticated user on this file.

fileExtension

string

Output only. The final component of fullFileExtension with trailing text that does not appear to be part of the extension removed. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files.

md5Checksum

string

Output only. An MD5 checksum for the content of this file. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files.

ownerNames[]

string

Output only. Name(s) of the owner(s) of this file. Not populated for items in shared drives.

lastModifyingUserName

string

Output only. Name of the last user to modify this file.

editable
(deprecated)

boolean

Output only. Deprecated: Use capabilities/canEdit instead.

writersCanShare

boolean

Whether writers can share the document with other users. Not populated for items in shared drives.

downloadUrl

string

Output only. Short lived download URL for the file. This field is only populated for files with content stored in Google Drive; it is not populated for Google Docs or shortcut files.

mimeType

string

The MIME type of the file. This is only mutable on update when uploading new content. This field can be left blank, and the mimetype will be determined from the uploaded content's MIME type.

driveId

string

Output only. ID of the shared drive the file resides in. Only populated for items in shared drives.

parents[]

object (ParentReference)

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 an insert 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 addParents and removeParents parameters to modify the parents list.

appDataContents

boolean

Output only. Whether this file is in the Application Data folder.

shared

boolean

Output only. Whether the file has been shared. Not populated for items in shared drives.

lastModifyingUser

object (User)

Output only. The last user to modify this file. This field is only populated when the last modification was performed by a signed-in user.

owners[]

object (User)

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

string

Output only. The ID of the file's head revision. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files.

properties[]

object (Property)

The list of properties.

copyable
(deprecated)

boolean

Output only. Deprecated: Use capabilities/canCopy instead.

etag

string

Output only. ETag of the file.

sharingUser

object (User)

Output only. User that shared the item with the current user, if available.

fileSize

string (int64 format)

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.

copyRequiresWriterPermission

boolean

Whether the options to copy, print, or download this file, should be disabled for readers and commenters.

permissions[]

object (Permission)

Output only. The list of permissions for users with access to this file. Not populated for items in shared drives.

hasThumbnail

boolean

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[]

string

Output only. The list of spaces which contain the file. Supported values are drive, appDataFolder and photos.

folderColorRgb

string

Folder color as an RGB hex string if the file is a folder or a shortcut to a folder. The list of supported colors is available in the folderColorPalette field of the About resource. If an unsupported color is specified, it will be changed to the closest color in the palette.

id

string

The ID of the file.

title

string

The title of this file. Note that for immutable items such as the top level folders of shared drives, My Drive root folder, and Application Data folder the title is constant.

description

string

A short description of the file.

labels

object

A group of labels for the file.

labels.viewed

boolean

Whether this file has been viewed by this user.

labels.restricted
(deprecated)

boolean

Output only. Deprecated: Use copyRequiresWriterPermission instead.

labels.starred

boolean

Whether this file is starred by the user.

labels.hidden
(deprecated)

boolean

Output only. Deprecated.

labels.trashed

boolean

Whether this file has been trashed. This label applies to all users accessing the file; however, only owners are allowed to see and untrash files.

labels.modified

boolean

Output only. Whether the file has been modified by this user.

explicitlyTrashed

boolean

Output only. Whether this file has been explicitly trashed, as opposed to recursively trashed.

createdDate

string

Output only. Create time for this file (formatted RFC 3339 timestamp).

modifiedDate

string

Last time this file was modified by anyone (formatted RFC 3339 timestamp). This is only mutable on update when the setModifiedDate parameter is set.

modifiedByMeDate

string

Output only. Last time this file was modified by the user (formatted RFC 3339 timestamp). Note that setting modifiedDate will also update the modifiedByMe date for the user which set the date.

lastViewedByMeDate

string

Last time this file was viewed by the user (formatted RFC 3339 timestamp).

markedViewedByMeDate
(deprecated)

string

Output only. Deprecated.

sharedWithMeDate

string

Output only. Time at which this file was shared with the user (formatted RFC 3339 timestamp).

quotaBytesUsed

string (int64 format)

Output only. The number of quota bytes used by this file.

version

string (int64 format)

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 requesting user.

indexableText

object

Indexable text attributes for the file (can only be written)

indexableText.text

string

The text to be indexed for this file.

originalFilename

string

The original filename of the uploaded content if available, or else the original value of the title field. This is only available for files with binary content in Google Drive.

ownedByMe

boolean

Output only. Whether the file is owned by the current user. Not populated for items in shared drives.

canComment
(deprecated)

boolean

Output only. Deprecated: Use capabilities/canComment instead.

shareable
(deprecated)

boolean

Output only. Deprecated: Use capabilities/canShare instead.

fullFileExtension

string

Output only. The full file extension; extracted from the title. May contain multiple concatenated extensions, such as "tar.gz". Removing an extension from the title does not clear this field; however, changing the extension on the title does update this field. This field is only populated for files with content stored in Google Drive; it is not populated for Docs Editors or shortcut files.

isAppAuthorized

boolean

Output only. Whether the file was created or opened by the requesting app.

teamDriveId
(deprecated)

string

Output only. Deprecated: Use driveId instead.

capabilities

object

Output only. Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.

capabilities.canChangeRestrictedDownload
(deprecated)

boolean

Output only. Deprecated.

capabilities.canMoveChildrenOutOfDrive

boolean

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

boolean

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

boolean

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 canChangeCopyRequiresWriterPermission or canModifyContent.

capabilities.canCopy

boolean

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

boolean

Output only. Whether the current user can comment on this file.

capabilities.canAddChildren

boolean

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

boolean

Output only. Whether the current user can delete this file.

capabilities.canDownload

boolean

Output only. Whether the current user can download this file.

capabilities.canListChildren

boolean

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

boolean

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 canDeleteChildren or canTrashChildren instead.

capabilities.canRename

boolean

Output only. Whether the current user can rename this file.

capabilities.canTrash

boolean

Output only. Whether the current user can move this file to trash.

capabilities.canReadRevisions

boolean

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)

boolean

Output only. Deprecated: Use canReadDrive instead.

capabilities.canMoveTeamDriveItem
(deprecated)

boolean

Output only. Deprecated: Use canMoveItemWithinDrive or canMoveItemOutOfDrive instead.

capabilities.canChangeCopyRequiresWriterPermission

boolean

Output only. Whether the current user can change the copyRequiresWriterPermission restriction of this file.

capabilities.canMoveItemIntoTeamDrive
(deprecated)

boolean

Output only. Deprecated: Use canMoveItemOutOfDrive instead.

capabilities.canUntrash

boolean

Output only. Whether the current user can restore this file from trash.

capabilities.canModifyContent

boolean

Output only. Whether the current user can modify the content of this file.

capabilities.canMoveItemWithinTeamDrive
(deprecated)

boolean

Output only. Deprecated: Use canMoveItemWithinDrive instead.

capabilities.canMoveItemOutOfTeamDrive
(deprecated)

boolean

Output only. Deprecated: Use canMoveItemOutOfDrive instead.

capabilities.canDeleteChildren

boolean

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)

boolean

Output only. Deprecated: Use canMoveChildrenOutOfDrive instead.

capabilities.canMoveChildrenWithinTeamDrive
(deprecated)

boolean

Output only. Deprecated: Use canMoveChildrenWithinDrive instead.

capabilities.canTrashChildren

boolean

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

boolean

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

boolean

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

boolean

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

boolean

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

boolean

Output only. Whether the current user can modify the sharing settings for this file.

capabilities.canMoveChildrenWithinDrive

boolean

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)

boolean

Deprecated: Output only. Use one of canModifyEditorContentRestriction, canModifyOwnerContentRestriction or canRemoveContentRestriction.

capabilities.canAddFolderFromAnotherDrive

boolean

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

boolean

Output only. Whether the current user can change the securityUpdateEnabled field on link share metadata.

capabilities.canAcceptOwnership

boolean

Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files.

capabilities.canReadLabels

boolean

Output only. Whether the current user can read the labels on the file.

capabilities.canModifyLabels

boolean

Output only. Whether the current user can modify the labels on the file.

capabilities.canModifyEditorContentRestriction

boolean

Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted.

capabilities.canModifyOwnerContentRestriction

boolean

Output only. Whether the current user can add or modify content restrictions which are owner restricted.

capabilities.canRemoveContentRestriction

boolean

Output only. Whether there is a content restriction on the file that can be removed by the current user.

hasAugmentedPermissions

boolean

Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives.

trashingUser

object (User)

Output only. If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives.

canReadRevisions
(deprecated)

boolean

Output only. Deprecated: Use capabilities/canReadRevisions instead.

thumbnailVersion

string (int64 format)

Output only. The thumbnail version for use in thumbnail cache invalidation.

trashedDate

string

Output only. The time that the item was trashed (formatted RFC 3339 timestamp). Only populated for items in shared drives.

permissionIds[]

string

Output only. files.list of permission IDs for users with access to this file.

thumbnail

object

A thumbnail for the file. This will only be used if a standard thumbnail cannot be generated.

thumbnail.image

string (bytes format)

The URL-safe Base64 encoded bytes of the thumbnail image. It should conform to RFC 4648 section 5.

A base64-encoded string.

thumbnail.mimeType

string

The MIME type of the thumbnail.

imageMediaMetadata

object

Output only. Metadata about image media. This will only be present for image types, and its contents will depend on what can be parsed from the image content.

imageMediaMetadata.flashUsed

boolean

Output only. Whether a flash was used to create the photo.

imageMediaMetadata.meteringMode

string

Output only. The metering mode used to create the photo.

imageMediaMetadata.sensor

string

Output only. The type of sensor used to create the photo.

imageMediaMetadata.exposureMode

string

Output only. The exposure mode used to create the photo.

imageMediaMetadata.colorSpace

string

Output only. The color space of the photo.

imageMediaMetadata.whiteBalance

string

Output only. The white balance mode used to create the photo.

imageMediaMetadata.width

integer

Output only. The width of the image in pixels.

imageMediaMetadata.height

integer

Output only. The height of the image in pixels.

imageMediaMetadata.location

object

Output only. Geographic location information stored in the image.

imageMediaMetadata.location.latitude

number

Output only. The latitude stored in the image.

imageMediaMetadata.location.longitude

number

Output only. The longitude stored in the image.

imageMediaMetadata.location.altitude

number

Output only. The altitude stored in the image.

imageMediaMetadata.rotation

integer

Output only. The number of clockwise 90 degree rotations applied from the image's original orientation.

imageMediaMetadata.date

string

Output only. The date and time the photo was taken (EXIF format timestamp).

imageMediaMetadata.cameraMake

string

Output only. The make of the camera used to create the photo.

imageMediaMetadata.cameraModel

string

Output only. The model of the camera used to create the photo.

imageMediaMetadata.exposureTime

number

Output only. The length of the exposure, in seconds.

imageMediaMetadata.aperture

number

Output only. The aperture used to create the photo (f-number).

imageMediaMetadata.focalLength

number

Output only. The focal length used to create the photo, in millimeters.

imageMediaMetadata.isoSpeed

integer

Output only. The ISO speed used to create the photo.

imageMediaMetadata.exposureBias

number

Output only. The exposure bias of the photo (APEX value).

imageMediaMetadata.maxApertureValue

number

Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value).

imageMediaMetadata.subjectDistance

integer

Output only. The distance to the subject of the photo, in meters.

imageMediaMetadata.lens

string

Output only. The lens used to create the photo.

videoMediaMetadata

object

Output only. Metadata about video media. This will only be present for video types.

videoMediaMetadata.width

integer

Output only. The width of the video in pixels.

videoMediaMetadata.height

integer

Output only. The height of the video in pixels.

videoMediaMetadata.durationMillis

string (int64 format)

Output only. The duration of the video in milliseconds.

shortcutDetails

object

Shortcut file details. Only populated for shortcut files, which have the mimeType field set to application/vnd.google-apps.shortcut. Can only be set on files.insert requests.

shortcutDetails.targetId

string

The ID of the file that this shortcut points to. Can only be set on files.insert requests.

shortcutDetails.targetMimeType

string

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

string

Output only. The ResourceKey for the target file.

contentRestrictions[]

object (ContentRestriction)

Restrictions for accessing the content of the file. Only populated if such a restriction exists.

resourceKey

string

Output only. A key needed to access the item via a shared link.

linkShareMetadata.securityUpdateEligible

boolean

Output only. Whether the file is eligible for security update.

linkShareMetadata.securityUpdateEnabled

boolean

Output only. Whether the security update is enabled for this file.

labelInfo

object

Output only. An overview of the labels on the file.

labelInfo.labels[]

object (Label)

Output only. The set of labels on the file as requested by the label IDs in the includeLabels parameter. By default, no labels are returned.

sha1Checksum

string

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

string

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 (User)
  },
  "restrictionDate": string,
  "ownerRestricted": boolean,
  "systemRestricted": boolean
}
Fields
readOnly

boolean

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

string

Reason for why the content of the file is restricted. This is only mutable on requests that also set readOnly=true.

type

string

Output only. The type of the content restriction. Currently the only possible value is globalContentRestriction.

restrictingUser

object (User)

Output only. The user who set the content restriction. Only populated if readOnly is true.

restrictionDate

string

Output only. The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if readOnly is true.

ownerRestricted

boolean

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 organizer capabilities can modify or remove this content restriction.

systemRestricted

boolean

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

copy

Creates a copy of the specified file.

delete

Permanently deletes a file owned by the user without moving it to the trash.

emptyTrash

Permanently deletes all of the user's trashed files.

export

Exports a Google Workspace document to the requested MIME type and returns exported byte content.

generateIds

Generates a set of file IDs which can be provided in insert or copy requests.

get

Gets a file's metadata or content by ID.

insert

Inserts a new file.

list

Lists the user's files.

listLabels

Lists the labels on a file.

modifyLabels

Modifies the set of labels applied to a file.

patch

Updates a file's metadata and/or content.

touch

Set the file's updated time to the current server time.

trash

Moves a file to the trash.

untrash

Restores a file from the trash.

update

Updates a file's metadata and/or content.

watch

Subscribes to changes to a file.