Creates a copy of a file and applies any requested updates with patch semantics.

Scopes

You will need authorization for at least one of the following scopes to make a valid call:

  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.appdata
  • https://www.googleapis.com/auth/drive.file
  • https://www.googleapis.com/auth/drive.photos.readonly

If unset, the scope for this method defaults to https://www.googleapis.com/auth/drive. You can set the scope for this method like this: drive3 --scope <scope> files copy ...

Required Scalar Argument

  • <file-id> (string)
    • The ID of the file.

Required Request Value

The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.

For example, a structure like this:

File:
  app-properties: { string: string }
  capabilities:
    can-accept-ownership: boolean
    can-add-children: boolean
    can-add-folder-from-another-drive: boolean
    can-add-my-drive-parent: boolean
    can-change-copy-requires-writer-permission: boolean
    can-change-security-update-enabled: boolean
    can-change-viewers-can-copy-content: boolean
    can-comment: boolean
    can-copy: boolean
    can-delete: boolean
    can-delete-children: boolean
    can-download: boolean
    can-edit: boolean
    can-list-children: boolean
    can-modify-content: boolean
    can-modify-content-restriction: boolean
    can-modify-editor-content-restriction: boolean
    can-modify-labels: boolean
    can-modify-owner-content-restriction: boolean
    can-move-children-out-of-drive: boolean
    can-move-children-out-of-team-drive: boolean
    can-move-children-within-drive: boolean
    can-move-children-within-team-drive: boolean
    can-move-item-into-team-drive: boolean
    can-move-item-out-of-drive: boolean
    can-move-item-out-of-team-drive: boolean
    can-move-item-within-drive: boolean
    can-move-item-within-team-drive: boolean
    can-move-team-drive-item: boolean
    can-read-drive: boolean
    can-read-labels: boolean
    can-read-revisions: boolean
    can-read-team-drive: boolean
    can-remove-children: boolean
    can-remove-content-restriction: boolean
    can-remove-my-drive-parent: boolean
    can-rename: boolean
    can-share: boolean
    can-trash: boolean
    can-trash-children: boolean
    can-untrash: boolean
  content-hints:
    indexable-text: string
    thumbnail:
      image: string
      mime-type: string
  copy-requires-writer-permission: boolean
  created-time: string
  description: string
  drive-id: string
  explicitly-trashed: boolean
  export-links: { string: string }
  file-extension: string
  folder-color-rgb: string
  full-file-extension: string
  has-augmented-permissions: boolean
  has-thumbnail: boolean
  head-revision-id: string
  icon-link: string
  id: string
  image-media-metadata:
    aperture: number
    camera-make: string
    camera-model: string
    color-space: string
    exposure-bias: number
    exposure-mode: string
    exposure-time: number
    flash-used: boolean
    focal-length: number
    height: integer
    iso-speed: integer
    lens: string
    location:
      altitude: number
      latitude: number
      longitude: number
    max-aperture-value: number
    metering-mode: string
    rotation: integer
    sensor: string
    subject-distance: integer
    time: string
    white-balance: string
    width: integer
  is-app-authorized: boolean
  kind: string
  last-modifying-user:
    display-name: string
    email-address: string
    kind: string
    me: boolean
    permission-id: string
    photo-link: string
  link-share-metadata:
    security-update-eligible: boolean
    security-update-enabled: boolean
  md5-checksum: string
  mime-type: string
  modified-by-me: boolean
  modified-by-me-time: string
  modified-time: string
  name: string
  original-filename: string
  owned-by-me: boolean
  parents: [string]
  permission-ids: [string]
  properties: { string: string }
  quota-bytes-used: string
  resource-key: string
  sha1-checksum: string
  sha256-checksum: string
  shared: boolean
  shared-with-me-time: string
  sharing-user:
    display-name: string
    email-address: string
    kind: string
    me: boolean
    permission-id: string
    photo-link: string
  shortcut-details:
    target-id: string
    target-mime-type: string
    target-resource-key: string
  size: string
  spaces: [string]
  starred: boolean
  team-drive-id: string
  thumbnail-link: string
  thumbnail-version: string
  trashed: boolean
  trashed-time: string
  trashing-user:
    display-name: string
    email-address: string
    kind: string
    me: boolean
    permission-id: string
    photo-link: string
  version: string
  video-media-metadata:
    duration-millis: string
    height: integer
    width: integer
  viewed-by-me: boolean
  viewed-by-me-time: string
  viewers-can-copy-content: boolean
  web-content-link: string
  web-view-link: string
  writers-can-share: boolean

can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.

  • -r . app-properties=key=dolor
    • 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.
    • the value will be associated with the given key
  • capabilities can-accept-ownership=true
    • Output only. Whether the current user is the pending owner of the file. Not populated for shared drive files.
  • can-add-children=true
    • Output only. Whether the current user can add children to this folder. This is always false when the item is not a folder.
  • can-add-folder-from-another-drive=true
    • 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.
  • can-add-my-drive-parent=false
    • 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.
  • can-change-copy-requires-writer-permission=true
    • Output only. Whether the current user can change the copyRequiresWriterPermission restriction of this file.
  • can-change-security-update-enabled=true
    • Output only. Whether the current user can change the securityUpdateEnabled field on link share metadata.
  • can-change-viewers-can-copy-content=true
    • Deprecated: Output only.
  • can-comment=true
    • Output only. Whether the current user can comment on this file.
  • can-copy=false
    • 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.
  • can-delete=true
    • Output only. Whether the current user can delete this file.
  • can-delete-children=false
    • 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.
  • can-download=true
    • Output only. Whether the current user can download this file.
  • can-edit=false
    • 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.
  • can-list-children=true
    • Output only. Whether the current user can list the children of this folder. This is always false when the item is not a folder.
  • can-modify-content=false
    • Output only. Whether the current user can modify the content of this file.
  • can-modify-content-restriction=true
    • Deprecated: Output only. Use one of canModifyEditorContentRestriction, canModifyOwnerContentRestriction or canRemoveContentRestriction.
  • can-modify-editor-content-restriction=false
    • Output only. Whether the current user can add or modify content restrictions on the file which are editor restricted.
  • can-modify-labels=true
    • Output only. Whether the current user can modify the labels on the file.
  • can-modify-owner-content-restriction=true
    • Output only. Whether the current user can add or modify content restrictions which are owner restricted.
  • can-move-children-out-of-drive=true
    • 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.
  • can-move-children-out-of-team-drive=false
    • Deprecated: Output only. Use canMoveChildrenOutOfDrive instead.
  • can-move-children-within-drive=false
    • 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.
  • can-move-children-within-team-drive=true
    • Deprecated: Output only. Use canMoveChildrenWithinDrive instead.
  • can-move-item-into-team-drive=false
    • Deprecated: Output only. Use canMoveItemOutOfDrive instead.
  • can-move-item-out-of-drive=true
    • 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.
  • can-move-item-out-of-team-drive=false
    • Deprecated: Output only. Use canMoveItemOutOfDrive instead.
  • can-move-item-within-drive=false
    • 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.
  • can-move-item-within-team-drive=true
    • Deprecated: Output only. Use canMoveItemWithinDrive instead.
  • can-move-team-drive-item=false
    • Deprecated: Output only. Use canMoveItemWithinDrive or canMoveItemOutOfDrive instead.
  • can-read-drive=true
    • Output only. Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives.
  • can-read-labels=false
    • Output only. Whether the current user can read the labels on the file.
  • can-read-revisions=true
    • 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.
  • can-read-team-drive=true
    • Deprecated: Output only. Use canReadDrive instead.
  • can-remove-children=true
    • 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.
  • can-remove-content-restriction=false
    • Output only. Whether there is a content restriction on the file that can be removed by the current user.
  • can-remove-my-drive-parent=false
    • 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.
  • can-rename=false
    • Output only. Whether the current user can rename this file.
  • can-share=true
    • Output only. Whether the current user can modify the sharing settings for this file.
  • can-trash=true
    • Output only. Whether the current user can move this file to trash.
  • can-trash-children=false
    • 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.
  • can-untrash=false

    • Output only. Whether the current user can restore this file from trash.
  • ..content-hints indexable-text=magna

    • Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements.
  • thumbnail image=diam
    • The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).
  • mime-type=nonumy

    • The MIME type of the thumbnail.
  • ... copy-requires-writer-permission=true

    • Whether the options to copy, print, or download this file, should be disabled for readers and commenters.
  • created-time=sed
    • The time at which the file was created (RFC 3339 date-time).
  • description=est
    • A short description of the file.
  • drive-id=takimata
    • Output only. ID of the shared drive the file resides in. Only populated for items in shared drives.
  • explicitly-trashed=false
    • Output only. Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.
  • export-links=key=diam
    • Output only. Links for exporting Docs Editors files to specific formats.
    • the value will be associated with the given key
  • file-extension=at
    • Output only. The final component of fullFileExtension. This is only available for files with binary content in Google Drive.
  • folder-color-rgb=erat
    • The color for a folder or a 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 is used instead.
  • full-file-extension=justo
    • Output only. The full file extension extracted from the name field. May contain multiple concatenated extensions, such as "tar.gz". This is only available for files with binary content in Google Drive. This is automatically updated when the name field changes, however it is not cleared if the new name does not contain a valid extension.
  • has-augmented-permissions=false
    • Output only. Whether there are permissions directly on this file. This field is only populated for items in shared drives.
  • has-thumbnail=false
    • 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.
  • head-revision-id=no
    • Output only. The ID of the file's head revision. This is currently only available for files with binary content in Google Drive.
  • icon-link=justo
    • Output only. A static, unauthenticated link to the file's icon.
  • id=sadipscing
    • The ID of the file.
  • image-media-metadata aperture=0.4609587543650727
    • Output only. The aperture used to create the photo (f-number).
  • camera-make=ipsum
    • Output only. The make of the camera used to create the photo.
  • camera-model=stet
    • Output only. The model of the camera used to create the photo.
  • color-space=gubergren
    • Output only. The color space of the photo.
  • exposure-bias=0.7523418315710285
    • Output only. The exposure bias of the photo (APEX value).
  • exposure-mode=sit
    • Output only. The exposure mode used to create the photo.
  • exposure-time=0.6912037612965762
    • Output only. The length of the exposure, in seconds.
  • flash-used=true
    • Output only. Whether a flash was used to create the photo.
  • focal-length=0.7922165291773876
    • Output only. The focal length used to create the photo, in millimeters.
  • height=13
    • Output only. The height of the image in pixels.
  • iso-speed=100
    • Output only. The ISO speed used to create the photo.
  • lens=sed
    • Output only. The lens used to create the photo.
  • location altitude=0.08117638318055986
    • Output only. The altitude stored in the image.
  • latitude=0.015343650487020133
    • Output only. The latitude stored in the image.
  • longitude=0.2992636384830838

    • Output only. The longitude stored in the image.
  • .. max-aperture-value=0.6596318919873574

    • Output only. The smallest f-number of the lens at the focal length used to create the photo (APEX value).
  • metering-mode=at
    • Output only. The metering mode used to create the photo.
  • rotation=20
    • Output only. The number of clockwise 90 degree rotations applied from the image's original orientation.
  • sensor=clita
    • Output only. The type of sensor used to create the photo.
  • subject-distance=25
    • Output only. The distance to the subject of the photo, in meters.
  • time=invidunt
    • Output only. The date and time the photo was taken (EXIF DateTime).
  • white-balance=nonumy
    • Output only. The white balance mode used to create the photo.
  • width=20

    • Output only. The width of the image in pixels.
  • .. is-app-authorized=true

    • Output only. Whether the file was created or opened by the requesting app.
  • kind=voluptua.
    • Output only. Identifies what kind of resource this is. Value: the fixed string &#34;drive#file&#34;.
  • last-modifying-user display-name=eos
    • Output only. A plain text displayable name for this user.
  • email-address=duo
    • Output only. The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
  • kind=elitr
    • Output only. Identifies what kind of resource this is. Value: the fixed string &#34;drive#user&#34;.
  • me=true
    • Output only. Whether this user is the requesting user.
  • permission-id=et
    • Output only. The user's ID as visible in Permission resources.
  • photo-link=clita

    • Output only. A link to the user's profile photo, if available.
  • ..link-share-metadata security-update-eligible=true

    • Output only. Whether the file is eligible for security update.
  • security-update-enabled=true

    • Output only. Whether the security update is enabled for this file.
  • .. md5-checksum=erat

    • Output only. The MD5 checksum for the content of the file. This is only applicable to files with binary content in Google Drive.
  • mime-type=diam
    • 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.
  • modified-by-me=true
    • Output only. Whether the file has been modified by this user.
  • modified-by-me-time=lorem
    • The last time the file was modified by the user (RFC 3339 date-time).
  • modified-time=at
    • he last time the file was modified by anyone (RFC 3339 date-time). Note that setting modifiedTime will also update modifiedByMeTime for the user.
  • name=diam
    • 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.
  • original-filename=diam
    • 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.
  • owned-by-me=false
    • Output only. Whether the user owns the file. Not populated for items in shared drives.
  • parents=et
    • The IDs of the parent folders which contain the file. 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 parents of the source file. Update requests must use the addParents and removeParents parameters to modify the parents list.
    • Each invocation of this argument appends the given value to the array.
  • permission-ids=ea
    • Output only. List of permission IDs for users with access to this file.
    • Each invocation of this argument appends the given value to the array.
  • properties=key=dolore
    • A collection of arbitrary key-value pairs which are visible to all apps. Entries with null values are cleared in update and copy requests.
    • the value will be associated with the given key
  • quota-bytes-used=ipsum
    • Output only. The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.
  • resource-key=ea
    • Output only. A key needed to access the item via a shared link.
  • sha1-checksum=at
    • 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.
  • sha256-checksum=sit
    • 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.
  • shared=false
    • Output only. Whether the file has been shared. Not populated for items in shared drives.
  • shared-with-me-time=lorem
    • The time at which the file was shared with the user, if applicable (RFC 3339 date-time).
  • sharing-user display-name=stet
    • Output only. A plain text displayable name for this user.
  • email-address=duo
    • Output only. The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
  • kind=elitr
    • Output only. Identifies what kind of resource this is. Value: the fixed string &#34;drive#user&#34;.
  • me=false
    • Output only. Whether this user is the requesting user.
  • permission-id=et
    • Output only. The user's ID as visible in Permission resources.
  • photo-link=lorem

    • Output only. A link to the user's profile photo, if available.
  • ..shortcut-details target-id=rebum.

    • The ID of the file that this shortcut points to.
  • target-mime-type=et
    • 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.
  • target-resource-key=sed

    • Output only. The ResourceKey for the target file.
  • .. size=stet

    • 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.
  • spaces=aliquyam
    • Output only. The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'.
    • Each invocation of this argument appends the given value to the array.
  • starred=false
    • Whether the user has starred the file.
  • team-drive-id=sit
    • Deprecated: Output only. Use driveId instead.
  • thumbnail-link=kasd
    • Output only. A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in Files.thumbnailLink must be fetched using a credentialed request.
  • thumbnail-version=tempor
    • Output only. The thumbnail version for use in thumbnail cache invalidation.
  • trashed=true
    • 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.
  • trashed-time=amet
    • The time that the item was trashed (RFC 3339 date-time). Only populated for items in shared drives.
  • trashing-user display-name=sit
    • Output only. A plain text displayable name for this user.
  • email-address=rebum.
    • Output only. The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
  • kind=sea
    • Output only. Identifies what kind of resource this is. Value: the fixed string &#34;drive#user&#34;.
  • me=false
    • Output only. Whether this user is the requesting user.
  • permission-id=ipsum
    • Output only. The user's ID as visible in Permission resources.
  • photo-link=et

    • Output only. A link to the user's profile photo, if available.
  • .. version=elitr

    • 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.
  • video-media-metadata duration-millis=eirmod
    • Output only. The duration of the video in milliseconds.
  • height=97
    • Output only. The height of the video in pixels.
  • width=6

    • Output only. The width of the video in pixels.
  • .. viewed-by-me=true

    • Output only. Whether the file has been viewed by this user.
  • viewed-by-me-time=consetetur
    • The last time the file was viewed by the user (RFC 3339 date-time).
  • viewers-can-copy-content=true
    • Deprecated: Use copyRequiresWriterPermission instead.
  • web-content-link=lorem
    • 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.
  • web-view-link=nonumy
    • Output only. A link for opening the file in a relevant Google editor or viewer in a browser.
  • writers-can-share=false
    • Whether users with only writer permission can modify the file's permissions. Not populated for items in shared drives.

About Cursors

The cursor position is key to comfortably set complex nested structures. The following rules apply:

  • The cursor position is always set relative to the current one, unless the field name starts with the . character. Fields can be nested such as in -r f.s.o .
  • The cursor position is set relative to the top-level structure if it starts with ., e.g. -r .s.s
  • You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify -r struct.sub_struct=bar.
  • You can move the cursor one level up by using ... Each additional . moves it up one additional level. E.g. ... would go three levels up.

Optional Output Flags

The method's return value a JSON encoded structure, which will be written to standard output by default.

  • -o out
    • out specifies the destination to which to write the server's result to. It will be a JSON-encoded structure. The destination may be - to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.

Optional Method Properties

You may set the following properties to further configure the call. Please note that -p is followed by one or more key-value-pairs, and is called like this -p k1=v1 k2=v2 even though the listing below repeats the -p for completeness.

  • -p enforce-single-parent=boolean

    • Deprecated. Copying files into multiple folders is no longer supported. Use shortcuts instead.
  • -p ignore-default-visibility=boolean

    • Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.
  • -p include-labels=string

    • A comma-separated list of IDs of labels to include in the labelInfo part of the response.
  • -p include-permissions-for-view=string

    • Specifies which additional view's permissions to include in the response. Only 'published' is supported.
  • -p keep-revision-forever=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.
  • -p ocr-language=string

    • A language hint for OCR processing during image import (ISO 639-1 code).
  • -p supports-all-drives=boolean

    • Whether the requesting application supports both My Drives and shared drives.
  • -p supports-team-drives=boolean

    • Deprecated: Use supportsAllDrives instead.

Optional General Properties

The following properties can configure any call, and are not specific to this method.

  • -p $-xgafv=string

    • V1 error format.
  • -p access-token=string

    • OAuth access token.
  • -p alt=string

    • Data format for response.
  • -p callback=string

    • JSONP
  • -p fields=string

    • Selector specifying which fields to include in a partial response.
  • -p key=string

    • API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
  • -p oauth-token=string

    • OAuth 2.0 token for the current user.
  • -p pretty-print=boolean

    • Returns response with indentations and line breaks.
  • -p quota-user=string

    • Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
  • -p upload-type=string

    • Legacy upload protocol for media (e.g. "media", "multipart").
  • -p upload-protocol=string

    • Upload protocol for media (e.g. "raw", "multipart").