log in
tour help
Dismiss
Ersel
1
What is the problem you are having? What have you tried? - Ed Cottrell
1 Answer
jjTS
pinoyyid
7,932
22
62
Files: list
Lists the user 's files. Try it now (#try-it) or see an example ( #examples).
Requests with files . list accept the q parameter, which is a search query combining one
or more search terms. For more information, see Search for files
(https:// developers.google.com/ drive/ search-parameters).
Note: This method returns all files by default. This includes files with trashed= true in the results. Use
the trashed= false query parameter to filter these from the results.
Request
HTTP request
GET https ://www.googleapis.com /drive/v2/files
Parameters
Parameter
name
Value
Description
corpus
string The body of items (files/ documents) to which the query applies.
string A comma-separated list of sort keys. Valid keys are 'createdDate', ' folder ',
'lastViewedByMeDate', 'modifiedByMeDate', 'modifiedDate', 'quotaBytesUsed',
'recency ', 'sharedWithMeDate', 'starred', and 'title'. Each key sorts ascending by
default, but may be reversed with the 'desc' modifier. Example usage: ?
orderBy = folder,modifiedDate desc,title. Please note that there is a current
limitation for users with approximately one million files in which the requested
sort order is ignored.
string
spaces
Query string
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
: etag ,
" selfLink " : string ,
" nextPageToken " : string ,
" nextLink " : string ,
" items " : [
files Resource ( https : / / developers . google . com / drive / v 2 / reference / files # re:
" etag "
Property name
Value
Description
kind
string
etag
etag
selfLink
string
Notes
nextPageToken
string
nextLink
string
items[]
list
Examples
Note: The code examples available for this method do not represent all supported programming
languages (see the client libraries page (https:// developers.google.com/ drive/ v2/ web/ downloads) for a
list of supported languages).
Java
Uses the Java client library (https:// developers.google.com/ drive/ v2/ web/ downloads).
import
import
import
import
II
...
II
...
Ikk
* Retrieve a list of File resources.
*
'
do {
try {
...
.NET
Uses the .NET client library (https:// developers.google.com/ drive/ v2/ web/ downloads).
using Google . Apis . Drive . v 2 ;
using Google . Apis . Drive . v 2 . Data ;
using System . Collections . Generic ;
n ...
...
II
III
III
do {
try {
...
PHP
Uses the PHP client library (https://developers.google.com/ drive/ v2/ web/ downloads).
/ 'k'k
Sresult
Python
...
result = [ ]
page.token = None
while True :
try :
param = { }
i f page.token :
param [ ' pageToken ' ] = page.token
f i l e s = service . f i l e s ( ) . l i s t ( param ) . execute ( )
**
JavaScript
Uses the JavaScript client library (https:// developers.google.com/ drive/ v 2/ web/ downloads)
/ **
* Retrieve a l i s t of File resources .
k
* @ param
*/
if (nextPageToken) {
request = gapi.client.drive .files.list({
' pageToken ' : nextPageToken
});
retrievePageOfFiles( request , result);
} else {
callback(result);
}
>
Go
Uses the Go client library (https:// developers.google.com/ drive/ v2/ web/ downloads).
import
-api-go-client /drive/v2"
)
fetches and displays all files
func AllFiles(d *drive.Service)([]*drive.File , error) {
var fs []*drive .File
pageToken := " "
for {
q := d .Files.List()
// If we have a pageToken set , apply it to the query
if pageToken ! = " " {
// AllFiles
= q .PageToken(pageToken)
}
r , err := q .Do()
if err ! = nil {
fmt.Printf(" An error occurred : %v\ n " , err)
return fs , err
}
fs = append(fs, r .Items...)
pageToken = r . NextPageToken
if pageToken == " " {
break
}
}
return fs , nil
Objective-C
Uses the Objective-C client library
(https:// developers.google.com/ drive/ v 2/ web / downloads).
#import " GTLDrive . h "
II
...
* ) ) completior
*f i l e s ,
//
...
Try it!
Use the APIs Explorer below to call this method on live data and see the response.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0
License (http: // creativecommons.Org / licenses / by / 3.0 / ), and code samples are licensed under the Apache 2.0
License (http:// www.apache.Org / licenses / LICENSE-2.0 ). For details, see our Site Policies
(https: // developers.google.com / site-policies). Java is a registered trademark of Oracle and / or its affiliates.
Last updated January 76, 2016.
Blog
Gooale+ Community
Add us to your circles and
connect with developers
l=J
GitHub
Explore our sample apps or
fork them to build your own
Stack Overflow
Ask questions with the googledrive-sdktag
Client Libraries
Download a client library to
help you get started