patch method
- File request,
- String fileId, {
- String? addParents,
- bool? convert,
- bool? enforceSingleParent,
- String? includeLabels,
- String? includePermissionsForView,
- String? modifiedDateBehavior,
- bool? newRevision,
- bool? ocr,
- String? ocrLanguage,
- bool? pinned,
- String? removeParents,
- bool? setModifiedDate,
- bool? supportsAllDrives,
- bool? supportsTeamDrives,
- String? timedTextLanguage,
- String? timedTextTrackName,
- bool? updateViewedDate,
- bool? useContentAsIndexableText,
- String? $fields,
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 change automatically, such as modifiedDate. This method supports patch semantics.
request
- The metadata request object.
Request parameters:
fileId
- The ID of the file to update.
addParents
- Comma-separated list of parent IDs to add.
convert
- Deprecated: This parameter has no function.
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.
modifiedDateBehavior
- Determines the behavior in which modifiedDate
is updated. This overrides setModifiedDate
.
Possible string values are:
- "fromBody" : Set
modifiedDate
to the value provided in the body of the request. No change if no value was provided. - "fromBodyIfNeeded" : Set
modifiedDate
to the value provided in the body of the request depending on other contents of the update. - "fromBodyOrNow" : Set modifiedDate to the value provided in the body of the request, or to the current time if no value was provided.
- "noChange" : Maintain the previous value of
modifiedDate
. - "now" : Set
modifiedDate
to the current time. - "nowIfNeeded" : Set
modifiedDate
to the current time depending on contents of the update.
newRevision
- Whether a blob upload should create a new revision. If
false, the blob data in the current head revision is replaced. If true or
not set, a new blob is created as head revision, and previous unpinned
revisions are preserved for a short period of time. Pinned revisions are
stored indefinitely, using additional storage quota, up to a maximum of
200 revisions. For details on how revisions are retained, see the
Drive Help Center. Note
that this field is ignored if there is no payload in the request.
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 new revision. A file can have a maximum of
200 pinned revisions. Note that this field is ignored if there is no
payload in the request.
removeParents
- Comma-separated list of parent IDs to remove.
setModifiedDate
- Whether to set the modified date using the value
supplied in the request body. Setting this field to true
is equivalent
to modifiedDateBehavior=fromBodyOrNow
, and false
is equivalent to
modifiedDateBehavior=now
. To prevent any changes to the modified date
set modifiedDateBehavior=noChange
.
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.
updateViewedDate
- Whether to update the view date after successfully
updating the file.
useContentAsIndexableText
- Whether to use the content as indexable
text.
$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> patch(
File request,
core.String fileId, {
core.String? addParents,
core.bool? convert,
core.bool? enforceSingleParent,
core.String? includeLabels,
core.String? includePermissionsForView,
core.String? modifiedDateBehavior,
core.bool? newRevision,
core.bool? ocr,
core.String? ocrLanguage,
core.bool? pinned,
core.String? removeParents,
core.bool? setModifiedDate,
core.bool? supportsAllDrives,
core.bool? supportsTeamDrives,
core.String? timedTextLanguage,
core.String? timedTextTrackName,
core.bool? updateViewedDate,
core.bool? useContentAsIndexableText,
core.String? $fields,
}) async {
final body_ = convert_1.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (addParents != null) 'addParents': [addParents],
if (convert != null) 'convert': ['${convert}'],
if (enforceSingleParent != null)
'enforceSingleParent': ['${enforceSingleParent}'],
if (includeLabels != null) 'includeLabels': [includeLabels],
if (includePermissionsForView != null)
'includePermissionsForView': [includePermissionsForView],
if (modifiedDateBehavior != null)
'modifiedDateBehavior': [modifiedDateBehavior],
if (newRevision != null) 'newRevision': ['${newRevision}'],
if (ocr != null) 'ocr': ['${ocr}'],
if (ocrLanguage != null) 'ocrLanguage': [ocrLanguage],
if (pinned != null) 'pinned': ['${pinned}'],
if (removeParents != null) 'removeParents': [removeParents],
if (setModifiedDate != null) 'setModifiedDate': ['${setModifiedDate}'],
if (supportsAllDrives != null)
'supportsAllDrives': ['${supportsAllDrives}'],
if (supportsTeamDrives != null)
'supportsTeamDrives': ['${supportsTeamDrives}'],
if (timedTextLanguage != null) 'timedTextLanguage': [timedTextLanguage],
if (timedTextTrackName != null)
'timedTextTrackName': [timedTextTrackName],
if (updateViewedDate != null) 'updateViewedDate': ['${updateViewedDate}'],
if (useContentAsIndexableText != null)
'useContentAsIndexableText': ['${useContentAsIndexableText}'],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'files/' + commons.escapeVariable('$fileId');
final response_ = await _requester.request(
url_,
'PATCH',
body: body_,
queryParams: queryParams_,
);
return File.fromJson(response_ as core.Map<core.String, core.dynamic>);
}