Update Drive File
update_drive_fileUpdate a Google Drive file's content and properties in one call, preserving its ID, sharing, comments, and links. Supports replace, append, or prepend text and metadata changes.
Instructions
Updates metadata, properties, and/or content of a Google Drive file.
Providing one of content, file_path, or file_url replaces the file's
content in place, preserving the existing file ID, sharing, comments, and links.
For native Google Docs/Sheets/Slides the source is uploaded with its source MIME
type so the Drive API applies the same format conversion as import_to_google_doc
(markdown headings, tables, bold, etc.). For any other file (.md, .txt, .pdf, ...)
there is nothing to convert, so the bytes are written back as-is under the file's
own MIME type. Metadata and content can be updated in a single call.
mode='append'/'prepend' splice content onto the file's existing text
server-side, so only the new text has to be supplied — no need to send the whole
file back to rewrite it.
Drive shortcuts are handled according to the kind of update: supported resource-local metadata changes (rename, move, trash, star, description, and custom properties) apply to the supplied shortcut, while content replacement follows the shortcut and updates its target. To avoid applying metadata to the wrong resource, a shortcut call cannot combine content with resource-local metadata. Update the shortcut metadata and target content in separate calls.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | How to apply the new content — 'replace' (default), 'append', or 'prepend'. Append/prepend require 'content' and a UTF-8 text file such as .md or .txt; a newline is inserted at the seam if neither side has one. For native Google Docs use insert_doc_elements, modify_doc_text, or find_and_replace_doc, which edit in place instead of rewriting the file. | replace |
| name | No | New name for the file. | |
| content | No | New text content for text-based formats (markdown, TXT, HTML). | |
| file_id | Yes | The ID of the file to update. Required. | |
| starred | No | Whether to star/unstar the file. | |
| trashed | No | Whether to move file to/from trash. | |
| file_url | No | Remote http(s) URL to fetch new content from. | |
| file_path | No | Local file path for binary formats (DOCX, ODT). Supports file:// URLs. | |
| mime_type | No | New MIME type (note: changing type may require content upload). For a shortcut ID, this must accompany content and applies to the resolved target. | |
| properties | No | Custom key-value properties for the file. | |
| add_parents | No | Comma-separated folder IDs to add as parents. | |
| description | No | New description for the file. | |
| source_format | No | Source format hint for conversion (md, markdown, docx, txt, html, rtf, odt). Auto-detected when omitted, and ignored for non-Google files, which are uploaded without conversion. Provide at most one of content/file_path/file_url. | |
| remove_parents | No | Comma-separated folder IDs to remove from parents. | |
| user_google_email | Yes | The user's Google email address. Required. | |
| writers_can_share | No | Whether editors can share the file. Pass the target ID directly; this cannot be changed on a shortcut resource. | |
| copy_requires_writer_permission | No | Whether copying requires writer permission. Pass the target ID directly; this cannot be changed on a shortcut resource. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |