copy method

Future<File> copy(
  1. File request,
  2. String fileId, {
  3. bool? enforceSingleParent,
  4. bool? ignoreDefaultVisibility,
  5. String? includeLabels,
  6. String? includePermissionsForView,
  7. bool? keepRevisionForever,
  8. String? ocrLanguage,
  9. bool? supportsAllDrives,
  10. bool? supportsTeamDrives,
  11. String? $fields,
})

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

request - The metadata request object.

Request parameters:

fileId - The ID of the file.

enforceSingleParent - Deprecated. Copying files into multiple folders is no longer supported. Use shortcuts instead.

ignoreDefaultVisibility - 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.

includeLabels - A comma-separated list of IDs of labels to include in the labelInfo part of the response.

includePermissionsForView - Specifies which additional view's permissions to include in the response. Only 'published' is supported.

keepRevisionForever - 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.

ocrLanguage - A language hint for OCR processing during image import (ISO 639-1 code).

supportsAllDrives - Whether the requesting application supports both My Drives and shared drives.

supportsTeamDrives - Deprecated: Use supportsAllDrives instead.

$fields - Selector specifying which fields to include in a partial response.

Completes with a File.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<File> copy(
  File request,
  core.String fileId, {
  core.bool? enforceSingleParent,
  core.bool? ignoreDefaultVisibility,
  core.String? includeLabels,
  core.String? includePermissionsForView,
  core.bool? keepRevisionForever,
  core.String? ocrLanguage,
  core.bool? supportsAllDrives,
  core.bool? supportsTeamDrives,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (enforceSingleParent != null)
      'enforceSingleParent': ['${enforceSingleParent}'],
    if (ignoreDefaultVisibility != null)
      'ignoreDefaultVisibility': ['${ignoreDefaultVisibility}'],
    if (includeLabels != null) 'includeLabels': [includeLabels],
    if (includePermissionsForView != null)
      'includePermissionsForView': [includePermissionsForView],
    if (keepRevisionForever != null)
      'keepRevisionForever': ['${keepRevisionForever}'],
    if (ocrLanguage != null) 'ocrLanguage': [ocrLanguage],
    if (supportsAllDrives != null)
      'supportsAllDrives': ['${supportsAllDrives}'],
    if (supportsTeamDrives != null)
      'supportsTeamDrives': ['${supportsTeamDrives}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'files/' + commons.escapeVariable('$fileId') + '/copy';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return File.fromJson(response_ as core.Map<core.String, core.dynamic>);
}