copy method
- File request,
- String fileId, {
- bool? convert,
- bool? enforceSingleParent,
- String? includeLabels,
- String? includePermissionsForView,
- bool? ocr,
- String? ocrLanguage,
- bool? pinned,
- bool? supportsAllDrives,
- bool? supportsTeamDrives,
- String? timedTextLanguage,
- String? timedTextTrackName,
- String? visibility,
- String? $fields,
Creates a copy of the specified file.
request - The metadata request object.
Request parameters:
fileId - The ID of the file to copy.
convert - Whether to convert this file to the corresponding Docs Editors
format.
enforceSingleParent - Deprecated: Copying files into multiple folders is
no longer supported. Use shortcuts instead.
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.
ocr - Whether to attempt OCR on .jpg, .png, .gif, or .pdf uploads.
ocrLanguage - If ocr is true, hints at the language to use. Valid
values are BCP 47 codes.
pinned - Whether to pin the head revision of the new copy. A file can
have a maximum of 200 pinned revisions.
supportsAllDrives - Whether the requesting application supports both My
Drives and shared drives.
supportsTeamDrives - Deprecated: Use supportsAllDrives instead.
timedTextLanguage - The language of the timed text.
timedTextTrackName - The timed text track name.
visibility - The visibility of the new file. Permissions are still
inherited from parent folders. This parameter is only relevant when the
source is not a Google Doc file and when convert=false.
Possible string values are:
- "DEFAULT" : The visibility of the new file is determined by the user's default visibility or sharing policies.
- "PRIVATE" : The user's default visibility or sharing policies are ignored, and the new file is only visible to the owner and any users with permissions inherited from the parent folder.
$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? convert,
core.bool? enforceSingleParent,
core.String? includeLabels,
core.String? includePermissionsForView,
core.bool? ocr,
core.String? ocrLanguage,
core.bool? pinned,
core.bool? supportsAllDrives,
core.bool? supportsTeamDrives,
core.String? timedTextLanguage,
core.String? timedTextTrackName,
core.String? visibility,
core.String? $fields,
}) async {
final body_ = convert_1.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
'convert': ?convert == null ? null : ['${convert}'],
'enforceSingleParent': ?enforceSingleParent == null
? null
: ['${enforceSingleParent}'],
'includeLabels': ?includeLabels == null ? null : [includeLabels],
'includePermissionsForView': ?includePermissionsForView == null
? null
: [includePermissionsForView],
'ocr': ?ocr == null ? null : ['${ocr}'],
'ocrLanguage': ?ocrLanguage == null ? null : [ocrLanguage],
'pinned': ?pinned == null ? null : ['${pinned}'],
'supportsAllDrives': ?supportsAllDrives == null
? null
: ['${supportsAllDrives}'],
'supportsTeamDrives': ?supportsTeamDrives == null
? null
: ['${supportsTeamDrives}'],
'timedTextLanguage': ?timedTextLanguage == null
? null
: [timedTextLanguage],
'timedTextTrackName': ?timedTextTrackName == null
? null
: [timedTextTrackName],
'visibility': ?visibility == null ? null : [visibility],
'fields': ?$fields == null ? null : [$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>);
}