download method

Future<Operation> download(
  1. String fileId, {
  2. String? mimeType,
  3. String? revisionId,
  4. String? $fields,
})

Downloads content of a file.

Operations are valid for 24 hours from the time of creation.

Request parameters:

fileId - Required. The ID of the file to download.

mimeType - Optional. The MIME type the file should be downloaded as. This field can only be set when downloading Google Workspace documents. See [Export MIME types for Google Workspace documents](/drive/api/guides/ref-export-formats) for the list of supported MIME types. If not set, a Google Workspace document is downloaded with a default MIME type. The default MIME type might change in the future.

revisionId - Optional. The revision ID of the file to download. This field can only be set when downloading blob files, Google Docs, and Google Sheets. Returns INVALID_ARGUMENT if downloading a specific revision on the file is unsupported.

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

Completes with a Operation.

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<Operation> download(
  core.String fileId, {
  core.String? mimeType,
  core.String? revisionId,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (mimeType != null) 'mimeType': [mimeType],
    if (revisionId != null) 'revisionId': [revisionId],
    if ($fields != null) 'fields': [$fields],
  };

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

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