Files: update

Stay organized with collections Save and categorize content based on your preferences.

Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might change automatically, such as modifiedDate. This method supports patch semantics. Try it now.

This method supports an /upload URI and accepts uploaded media with the following characteristics:

  • Maximum file size: 5120GB
  • Accepted Media MIME types: */*

Note: Specify a valid MIME type, rather than the literal */* value. The literal */* is only used to indicate that any valid MIME type can be uploaded.

Request

HTTP request

This method provides media upload functionality through two separate URIs. For more details, see the document on media upload.

  • Upload URI, for media upload requests:
    PATCH https://www.googleapis.com/upload/drive/v3/files/fileId
  • Metadata URI, for metadata-only requests:
    PATCH https://www.googleapis.com/drive/v3/files/fileId

Parameters

Parameter name Value Description
Path parameters
fileId string The ID of the file.
Required query parameters
uploadType string The type of upload request to the /upload URI. If you are uploading data (using an /upload URI), this field is required. If you are creating a metadata-only file, this field is not required. Additionally, this field is not shown in the "Try this API" widget because the widget doesn't support data uploads. Acceptable values are:
  • media - Simple upload. Upload the media only, without any metadata.
  • multipart - Multipart upload. Upload both the media and its metadata, in a single request.
  • resumable - Resumable upload. Upload the file in a resumable fashion, using a series of at least two requests where the first request includes the metadata.
Optional query parameters
addParents string A comma-separated list of parent IDs to add.
enforceSingleParent boolean Deprecated. Adding files to multiple folders is no longer supported. Use shortcuts instead. (Default: false)
includeLabels string A comma-separated list of IDs of labels to include in the labelInfo part of the response.
includePermissionsForView string Specifies which additional view's permissions to include in the response. Only 'published' is supported.
keepRevisionForever boolean Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions. (Default: false)
ocrLanguage string A language hint for OCR processing during image import (ISO 639-1 code).
removeParents string A comma-separated list of parent IDs to remove.
supportsAllDrives boolean Whether the requesting application supports both My Drives and shared drives. (Default: false)
supportsTeamDrives boolean Deprecated use supportsAllDrives instead. (Default: false)
useContentAsIndexableText boolean Whether to use the uploaded content as indexable text. (Default: false)

Authorization

This request requires authorization with at least one of the following scopes:

Scope
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.scripts
https://www.googleapis.com/auth/drive.metadata

Some scopes are restricted and require a security assessment for your app to use them. For more information, see the authentication and authorization page.

Request body

In the request body, supply the relevant portions of a Files resource, according to the rules of patch semantics, with the following properties:

Property name Value Description Notes
Optional Properties
appProperties object 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 a OAuth 2 client ID. You cannot use an API key to retrieve private properties.

writable
contentHints.indexableText string Text to be indexed for the file to improve fullText queries. This is limited to 128 KB in length and may contain HTML elements. For more information, see Manage file metadata. writable
contentHints.thumbnail.image bytes The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5). writable
contentHints.thumbnail.mimeType string The MIME type of the thumbnail. writable
contentRestrictions[].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. writable
contentRestrictions[].reason string Reason for why the content of the file is restricted. This is only mutable on requests that also set readOnly=true. writable
copyRequiresWriterPermission boolean Whether the options to copy, print, or download this file, should be disabled for readers and commenters. writable
description string A short description of the file. writable
folderColorRgb string The color for a folder or shortcut to a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the About resource.

If an unsupported color is specified, the closest color in the palette will be used instead.

writable
mimeType string The MIME type of the file.

Google Drive will attempt 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 will be imported if possible. The supported import formats are published in the About resource.

writable
modifiedTime datetime The last time the file was modified by anyone (RFC 3339 date-time).

Note that setting modifiedTime will also update modifiedByMeTime for the user.

writable
name string 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. writable
originalFilename string The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Google Drive. writable
properties object A collection of arbitrary key-value pairs which are visible to all apps.

Entries with null values are cleared in update and copy requests.

writable
starred boolean Whether the user has starred the file. writable
trashed boolean Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file. The trashed item is excluded from all files.list responses returned for any user who does not own the file. However, all users with access to the file can see the trashed item metadata in an API response. All users with access can copy, download, export, and share the file. writable
viewedByMeTime datetime The last time the file was viewed by the user (RFC 3339 date-time). writable
writersCanShare boolean Whether users with only writer permission can modify the file's permissions. Not populated for items in shared drives. writable

Response

If successful, this method returns a Files resource in the response body.

Try it!

Note: APIs Explorer currently supports metadata requests only.

Use the APIs Explorer below to call this method on live data and see the response.