請注意,系統不支援預先產生的 ID 來建立 Google Workspace 檔案,但 application/vnd.google-apps.drive-sdk 和 application/vnd.google-apps.folderMIME 類型除外。同樣地,系統也不支援上傳參照轉換為 Google Workspace 檔案格式的檔案。
[[["容易理解","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-27 (世界標準時間)。"],[],[],null,["# Create and manage files\n\nThis guide explains how to create and manage files in Google Drive using the\nGoogle Drive API.\n\nCreate file\n-----------\n\nTo create a file in Drive that contains no metadata or content,\nuse the [`files.create`](/workspace/drive/api/reference/rest/v3/files/create) method with no\nparameters. The file is given a `kind` of `drive.file`, an `id`, a `name` of\n\"Untitled\", and a `mimeType` of `application/octet-stream`. The `uploadType` is\nmarked as required but defaults to `media`, so you don't actually have to supply\nit.\n\nFor more information about Drive file limits, see [File and\nfolder limits](/workspace/drive/api/guides/folder#folder-limits).\n| **Note:** When a Drive user wants to download a file, or when the file is downloaded through the sync client, Drive builds a full filename (with extension) based on the name. In cases where the extension is missing, Drive attempts to determine the extension based on the file's [MIME type](/workspace/drive/api/guides/mime-types).\n\nCreate metadata-only files\n--------------------------\n\nMetadata-only files contain no content. Metadata is data (such as `name`,\n`mimeType`, and `createdTime`) that describes the file. Fields like `name` are\nuser-agnostic and appear the same for each user, whereas fields such as\n`viewedByMeTime` contain user-specific values.\n\nOne example of a metadata-only file is a folder with the MIME type\n`application/vnd.google-apps.folder`. For more information, see [Create and\npopulate folders](/workspace/drive/api/guides/folder). Another example is a shortcut that\npoints to another file on Drive with the MIME type\n`application/vnd.google-apps.shortcut`. For more information, see [Create a\nshortcut to a Drive file](/workspace/drive/api/guides/shortcuts).\n\nManage thumbnail images\n-----------------------\n\nThumbnails help users identify Drive files. Drive\ncan automatically generate thumbnails for common file types or you can provide a\nthumbnail image generated by your app. For more information, see [Upload\nthumbnails](/workspace/drive/api/guides/file#upload-thumbnails).\n\nCopy an existing file\n---------------------\n\nTo copy a file, and apply any requested updates, use the [`files.copy`](/workspace/drive/api/reference/rest/v3/files/copy) method. To find the `fileId` to copy, use the\n[`files.list`](/workspace/drive/api/reference/rest/v3/files/list) method.\n\nNote that you need to use an appropriate [Drive API\nscope](/workspace/drive/api/reference/rest/v3/files/copy#authorization-scopes) to authorize the\ncall. For more information on Drive scopes, see [Choose\nGoogle Drive API scopes](/workspace/drive/api/guides/api-specific-auth).\n\n### Limits and considerations\n\nAs you prepare to copy files, take note of these limits and considerations:\n\n- **Permissions**:\n\n - The [`DownloadRestrictionsMetadata`](/workspace/drive/api/reference/rest/v3/files#downloadrestrictionsmetadata) object of the [`files`](/workspace/drive/api/reference/rest/v3/files) resource determines who can copy the file. For more information, see [Prevent users from\n downloading, printing, or copying your\n file](/workspace/drive/api/guides/content-restrictions#download-print-copy).\n - The `capabilities.canCopy` field resource determines whether the user can copy a file. For more information, see [Understand file\n capabilities](/workspace/drive/api/guides/manage-sharing#capabilities).\n - The user that created the copy owns the copied file. No other sharing settings from the source file are replicated. If the copy is created in a shared folder, it inherits the permissions of that folder.\n - A copied file's ownership might change and the copy might not inherit the original file's sharing settings. These settings might need to be reset.\n- **File management**:\n\n - Some files, like [third-party\n shortcuts](/workspace/drive/api/guides/third-party-shortcuts), can never be copied.\n - You can only copy a file into one parent folder. Specifying multiple parents isn't supported. If the `parents` field isn't specified, the file inherits any discoverable parents from the source file.\n - Even though a folder is a type of file, you can't copy a folder. Instead, create a destination folder and set the `parents` field of the existing files to the destination folder. You can then delete the original source folder.\n - Unless a new filename is specified, the `files.copy` method produces a file with the same name as the original.\n - Excessive use of `files.copy` can lead to exceeding your Drive API quota limits. For more information, see [Usage\n limits](/workspace/drive/api/guides/limits).\n\nRelated topics\n--------------\n\nHere are a few next steps you might try:\n\n- To upload file data when you create or update a file, see [Upload file\n data](/workspace/drive/api/guides/manage-uploads).\n\n- To create a file in a specific folder, see [Create a file in a specific\n folder](/workspace/drive/api/guides/folder#create-file).\n\n- To move files, see [Move files between\n folders](/workspace/drive/api/guides/folder#move-files).\n\n- To work with file metadata, see [Manage file metadata](/workspace/drive/api/guides/file).\n\n- To delete a file, see [Trash or delete files and\n folders](/workspace/drive/api/guides/delete)."]]