update method
- File request,
- String fileId, {
- String? addParents,
- bool? enforceSingleParent,
- String? includeLabels,
- String? includePermissionsForView,
- bool? keepRevisionForever,
- String? ocrLanguage,
- String? removeParents,
- bool? supportsAllDrives,
- bool? supportsTeamDrives,
- bool? useContentAsIndexableText,
- String? $fields,
- UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
- Media? uploadMedia,
Updates a file's metadata and/or content.
When calling this method, only populate fields in the request that you
want to modify. When updating fields, some fields might be changed
automatically, such as modifiedDate
. This method supports patch
semantics. This method supports an * / upload* URI and accepts uploaded
media with the following characteristics: - Maximum file size: 5,120 GB
- Accepted Media MIME types:
* / *
Note: Specify a valid MIME type, rather than the literal* / *
value. The literal* / *
is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see [Upload file data](/drive/api/guides/manage-uploads).
request
- The metadata request object.
Request parameters:
fileId
- The ID of the file.
addParents
- A comma-separated list of parent IDs to add.
enforceSingleParent
- Deprecated: Adding files to 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.
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).
removeParents
- A comma-separated list of parent IDs to remove.
supportsAllDrives
- Whether the requesting application supports both My
Drives and shared drives.
supportsTeamDrives
- Deprecated: Use supportsAllDrives
instead.
useContentAsIndexableText
- Whether to use the uploaded content as
indexable text.
$fields
- Selector specifying which fields to include in a partial
response.
uploadMedia
- The media to upload.
uploadOptions
- Options for the media upload. Streaming Media without
the length being known ahead of time is only supported via resumable
uploads.
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> update(
File request,
core.String fileId, {
core.String? addParents,
core.bool? enforceSingleParent,
core.String? includeLabels,
core.String? includePermissionsForView,
core.bool? keepRevisionForever,
core.String? ocrLanguage,
core.String? removeParents,
core.bool? supportsAllDrives,
core.bool? supportsTeamDrives,
core.bool? useContentAsIndexableText,
core.String? $fields,
commons.UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
commons.Media? uploadMedia,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (addParents != null) 'addParents': [addParents],
if (enforceSingleParent != null)
'enforceSingleParent': ['${enforceSingleParent}'],
if (includeLabels != null) 'includeLabels': [includeLabels],
if (includePermissionsForView != null)
'includePermissionsForView': [includePermissionsForView],
if (keepRevisionForever != null)
'keepRevisionForever': ['${keepRevisionForever}'],
if (ocrLanguage != null) 'ocrLanguage': [ocrLanguage],
if (removeParents != null) 'removeParents': [removeParents],
if (supportsAllDrives != null)
'supportsAllDrives': ['${supportsAllDrives}'],
if (supportsTeamDrives != null)
'supportsTeamDrives': ['${supportsTeamDrives}'],
if (useContentAsIndexableText != null)
'useContentAsIndexableText': ['${useContentAsIndexableText}'],
if ($fields != null) 'fields': [$fields],
};
core.String url_;
if (uploadMedia == null) {
url_ = 'files/' + commons.escapeVariable('$fileId');
} else if (uploadOptions is commons.ResumableUploadOptions) {
url_ = '/resumable/upload/drive/v3/files/' +
commons.escapeVariable('$fileId');
} else {
url_ = '/upload/drive/v3/files/' + commons.escapeVariable('$fileId');
}
final response_ = await _requester.request(
url_,
'PATCH',
body: body_,
queryParams: queryParams_,
uploadMedia: uploadMedia,
uploadOptions: uploadOptions,
);
return File.fromJson(response_ as core.Map<core.String, core.dynamic>);
}