Java list File sort by name

Note: Authorization optional.

Lists or searches files. Try it now.

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 guide.

Request

HTTP request

GET //www.googleapis.com/drive/v3/files

Parameters

Parameter name Value Description
Optional query parameters
corpora string Groupings of files to which the query applies. Supported groupings are: 'user' [files created by, opened by, or shared directly with the user], 'drive' [files in the specified shared drive as indicated by the 'driveId'], 'domain' [files shared to the user's domain], and 'allDrives' [A combination of 'user' and 'drive' for all drives where the user is a member]. When able, use 'user' or 'drive', instead of 'allDrives', for efficiency.
corpus string Warning: This item is deprecated. The source of files to list. Deprecated: use 'corpora' instead.

Acceptable values are:
  • "domain": Files shared to the user's domain.
  • "user": Files owned by or shared to the user. If a user has permissions on a Shared Drive, the files inside it won't be retrieved unless the user has created, opened, or shared the file.
driveId string ID of the shared drive to search.
fields string The paths of the fields you want included in the response. If not specified, the response includes a default set of fields specific to this method. For development you can use the special value * to return all fields, but you'll achieve greater performance by only selecting the fields you need. For more information, see Return specific fields for a file.
includeItemsFromAllDrives boolean Whether both My Drive and shared drive items should be included in results. [Default: false]
includePermissionsForView string Specifies which additional view's permissions to include in the response. Only 'published' is supported.
includeTeamDriveItems boolean Warning: This item is deprecated. Deprecated use includeItemsFromAllDrives instead. [Default: false]
orderBy string A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.
pageSize integer 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. Acceptable values are 1 to 1000, inclusive. [Default: 100]
pageToken string 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 string A query for filtering the file results. See the "Search for files" guide for the supported syntax.
spaces string A comma-separated list of spaces to query within the corpus. Supported values are 'drive' and 'appDataFolder'.
supportsAllDrives boolean Whether the requesting application supports both My Drives and shared drives. [Default: false]
supportsTeamDrives boolean Warning: This item is deprecated. Deprecated use supportsAllDrives instead. [Default: false]
teamDriveId string Warning: This item is deprecated. Deprecated use driveId instead.

Authorization

This request allows authorization with at least one of the following scopes:

Scope
//www.googleapis.com/auth/drive
//www.googleapis.com/auth/drive.file
//www.googleapis.com/auth/drive.readonly
//www.googleapis.com/auth/drive.metadata.readonly
//www.googleapis.com/auth/drive.appdata
//www.googleapis.com/auth/drive.metadata
//www.googleapis.com/auth/drive.photos.readonly

Some scopes are restricted and require a security assessment for your app to use them. For more information, see the authentication and authorization page.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{ "kind": "drive#fileList", "nextPageToken": string, "incompleteSearch": boolean, "files": [ files Resource ] } Property name Value Description Notes
kind string Identifies what kind of resource this is. Value: the fixed string "drive#fileList".
nextPageToken string The page token for the next page of files. This will be absent if the end of the files list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
files[] list The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
incompleteSearch boolean Whether the search process was incomplete. If true, then some search results may be missing, since all documents were not searched. This may occur when searching multiple drives with the "allDrives" corpora, but all corpora could not be searched. When this happens, it is suggested that clients narrow their query by choosing a different corpus such as "user" or "drive".

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Video liên quan

Chủ Đề