list method
- String? corpora,
- String? corpus,
- String? driveId,
- bool? includeItemsFromAllDrives,
- String? includeLabels,
- String? includePermissionsForView,
- bool? includeTeamDriveItems,
- String? orderBy,
- int? pageSize,
- String? pageToken,
- String? q,
- String? spaces,
- bool? supportsAllDrives,
- bool? supportsTeamDrives,
- String? teamDriveId,
- String? $fields,
Lists the user's files.
This method accepts the q
parameter, which is a search query combining
one or more search terms. For more information, see the [Search for files
& folders](/drive/api/guides/search-files) guide. Note: This method
returns all files by default, including trashed files. If you don't want
trashed files to appear in the list, use the trashed=false
query
parameter to remove trashed files from the results.
Request parameters:
corpora
- Bodies of items (files/documents) to which the query applies.
Supported bodies are 'user', 'domain', 'drive', and 'allDrives'. Prefer
'user' or 'drive' to 'allDrives' for efficiency. By default, corpora is
set to 'user'. However, this can change depending on the filter set
through the 'q' parameter.
corpus
- Deprecated: The source of files to list. Use 'corpora' instead.
Possible string values are:
- "domain" : Files shared to the user's domain.
- "user" : Files owned by or shared to the user.
driveId
- ID of the shared drive to search.
includeItemsFromAllDrives
- Whether both My Drive and shared drive items
should be included in results.
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.
includeTeamDriveItems
- Deprecated: Use includeItemsFromAllDrives
instead.
orderBy
- A comma-separated list of sort keys. Valid keys are: *
createdTime
: When the file was created. * folder
: The folder ID. This
field is sorted using alphabetical ordering. * modifiedByMeTime
: The
last time the file was modified by the user. * modifiedTime
: The last
time the file was modified by anyone. * name
: The name of the file. This
field is sorted using alphabetical ordering, so 1, 12, 2, 22. *
name_natural
: The name of the file. This field is sorted using natural
sort ordering, so 1, 2, 12, 22. * quotaBytesUsed
: The number of storage
quota bytes used by the file. * recency
: The most recent timestamp from
the file's date-time fields. * sharedWithMeTime
: When the file was
shared with the user, if applicable. * starred
: Whether the user has
starred the file. * viewedByMeTime
: The last time the file was viewed by
the user. Each key sorts ascending by default, but can be reversed with
the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name
.
pageSize
- The maximum number of files to return per page. Partial or
empty result pages are possible even before the end of the files list has
been reached.
Value must be between "1" and "1000".
pageToken
- The token for continuing a previous list request on the next
page. This should be set to the value of 'nextPageToken' from the previous
response.
q
- A query for filtering the file results. See the "Search for files &
folders" guide for supported syntax.
spaces
- A comma-separated list of spaces to query within the corpora.
Supported values are 'drive' and 'appDataFolder'.
supportsAllDrives
- Whether the requesting application supports both My
Drives and shared drives.
supportsTeamDrives
- Deprecated: Use supportsAllDrives
instead.
teamDriveId
- Deprecated: Use driveId
instead.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a FileList.
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<FileList> list({
core.String? corpora,
core.String? corpus,
core.String? driveId,
core.bool? includeItemsFromAllDrives,
core.String? includeLabels,
core.String? includePermissionsForView,
core.bool? includeTeamDriveItems,
core.String? orderBy,
core.int? pageSize,
core.String? pageToken,
core.String? q,
core.String? spaces,
core.bool? supportsAllDrives,
core.bool? supportsTeamDrives,
core.String? teamDriveId,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
if (corpora != null) 'corpora': [corpora],
if (corpus != null) 'corpus': [corpus],
if (driveId != null) 'driveId': [driveId],
if (includeItemsFromAllDrives != null)
'includeItemsFromAllDrives': ['${includeItemsFromAllDrives}'],
if (includeLabels != null) 'includeLabels': [includeLabels],
if (includePermissionsForView != null)
'includePermissionsForView': [includePermissionsForView],
if (includeTeamDriveItems != null)
'includeTeamDriveItems': ['${includeTeamDriveItems}'],
if (orderBy != null) 'orderBy': [orderBy],
if (pageSize != null) 'pageSize': ['${pageSize}'],
if (pageToken != null) 'pageToken': [pageToken],
if (q != null) 'q': [q],
if (spaces != null) 'spaces': [spaces],
if (supportsAllDrives != null)
'supportsAllDrives': ['${supportsAllDrives}'],
if (supportsTeamDrives != null)
'supportsTeamDrives': ['${supportsTeamDrives}'],
if (teamDriveId != null) 'teamDriveId': [teamDriveId],
if ($fields != null) 'fields': [$fields],
};
const url_ = 'files';
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return FileList.fromJson(response_ as core.Map<core.String, core.dynamic>);
}