sign up
log in
tour help
Dismiss
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help .
Whether you're a beginner or an experienced developer, you can contribute.
Sign up and start helping
Learn more about Documentation >
Google Drive Full Text Search implementation
I can use google cloud storage Download and upload static file for example pdf. Now I want use full text search with google drive
api for c# code
google drive sdk
asked Dec 5 '13 at 22:18
Ersel
1
What is the problem you are having? What have you tried? - Ed Cottrell
I dont know google drive full text search c # code?
How can I help get? - Ersel Dec 5 '13 at 23:21
1 Answer
everything you need is on this page
https ://developers.google.com/drive/v 2/reference/fil
es/list
answered Dec 6 '13 at 10:13
jjTS
pinoyyid
7,932
22
Dec 5 '13 at 22:45
Ersel Dec 5 '13 at 23:21
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
Optional query parameters
corpus
string The body of items (files/ documents) to which the query applies.
Acceptable values are:
" DEFAULT": The items that the user has accessed.
"DOMAIN": Items shared to the user 's domain.
maxResultsintegerMaximum number of files to return. Acceptable values are 0 to 1000, inclusive.
(Default: 100)
orderBy
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.
pageToken string Page token for files.
projectionstring This parameter is deprecated and has no function.
Acceptable values are:
" BASIC ": Deprecated
"FULL ": Deprecated
for searching files. See Searching for files
(https:// developers.google.com/ drive/ search-parameters) for more information
about supported fields and operations.
string
spaces
string A comma-separated list of spaces to query. Supported values are 'drive',
'appDataFolder ' and 'photos '.
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:
" kind " : " drive# fileList " ,
: 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
This is always drive #fileList.
etag
etag
The ETag of the list.
selfLink
string
A link back to this list.
Notes
nextPageToken
string
The page token for the next page of files.
nextLink
string
A link to the next page of files.
items[]
list
The actual list of files.
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
com .google .api.services.drive .Drive ;
com .google .api.services.drive .Drive.Files ;
com .google .api.services.drive .model.File ;
com .google .api.services.drive .model.FileList ;
import java .io .IOException ;
import java . util.ArrayList ;
import java . util.List ;
II
...
public class MyClass {
II
...
Ikk
* Retrieve a list of File resources.
*
'
* @param service Drive API service instance.
* @return List of File resources.
*/
private static List < File> retrieveAHFiles(Drive service) throws IOExceptior
List < File> result = new ArrayList < File>();
Files.List request = service .files().list();
do {
try {
FileList files = request . execute ( ) ;
result . addAll ( files . getltems ( ) ) ;
request . setPageToken ( files , getNextPageToken ( ) ) ;
} catch ( IOException e ) {
System . out . println ( " An error occurred : " + e ) ;
request . setPageToken ( null ) ;
}
} while ( request . getPageToken ( ) ! = null &&
request . getPageToken ( ) . length ( ) > 0 ) ;
return result ;
...
.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 ...
public class MyClass {
...
II
III
III
< summary >
Retrieve a l i s t of File resources .
Ill < / summary >
III < param name = " service " >Drive API service instance . < / param>
III < returns >List of File resources . < / returns >
public static List < File > retrieveAHFiles ( DriveService service ) {
List < File > result = new List <File > ( ) ;
FilesResource . ListRequest request = service . Files . List ( ) ;
do {
try {
FileList files = request . Execute ( ) ;
result . AddRange ( files . Items ) ;
request . PageToken = f i l e s . NextPageToken ;
} catch ( Exception e ) {
Console . WriteLine ( " An error occurred : " + e . Message ) ;
request . PageToken = null ;
}
} while ( ! String . IsNullOrEmpty ( request . PageToken ) ) ;
return result ;
...
PHP
Uses the PHP client library (https://developers.google.com/ drive/ v2/ web/ downloads).
/ 'k'k
* Retrieve a l i s t of File resources .
*
* @@ param Google _ Service _ Drive $_ service _ Drive _ API service instance .
* return Array L i s t of Google Service Drive DriveFile resources .
*/
function retrieveAHFiles ( $ service ) {
$ result = array ( ) ;
$pageToken = NULL ;
do {
try {
$ parameters = array ( ) ;
i f ( $ pageToken ) {
$parameters [ ' pageToken ' ] = $ pageToken ;
}
$ f i l e s = $ service - > f i l e s - > l i s t F i l e s ( $ parameters ) ;
Sresult
= array _ merge ( $ result , $ f i l e s - > getltems ( ) ) ;
$ pageToken = $ f i l e s - > getNextPageToken ( ) ;
} catch ( Exception $ e ) {
print " An error occurred : " . $ e - > getMessage ( ) ;
SpageToken = NULL ;
}
} while ( $pageToken ) ;
return $ result ;
Python
Uses the Python client library (https://developers.google.com / drive/ v 2/ web/ downloads).
from apiclient import errors
...
def retrieve _ a l l _ f i l e s ( service ) :
" " " Retrieve a l i s t of File resources .
Args :
service : Drive API service instance .
Returns :
List of File resources .
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 ( )
**
result . extend ( f i l e s [ ' items ] )
page.token = f i l e s . get ( ' nextPageToken )
i f not page.token :
break
except errors . HttpError , error :
print ' An error occurred : % s ' % error
break
return result
1
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
*/
{ Function } callback Function t o c a l l when the request i s complete .
function retrieveAHFiles ( callback ) {
var retrievePageOfFiles = function ( request , result ) {
request , execute ( function ( resp ) {
result = result . concat ( resp . items ) ;
var nextPageToken = resp . nextPageToken ;
if (nextPageToken) {
request = gapi.client.drive .files.list({
' pageToken ' : nextPageToken
});
retrievePageOfFiles( request , result);
} else {
callback(result);
}
>
var initialRequest = gapi.client.drive .files.list();
retrievePageOfFiles(initialRequest , []);
Go
Uses the Go client library (https:// developers.google.com/ drive/ v2/ web/ downloads).
import
" code .google .com / p /google
-api-go-client /drive/v2"
" fmt "
)
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
...
+ ( void ) retrieveAUFilesWithService : ( GTLServiceDrive * ) service
completionBlock : ( void ( A ) ( NSArray , NSError
*
* ) ) completior
/ / The service can be set t o automatically fetch a l l pages of the result . Me
/ / can be found on < a href = " https : / / code . google . com / p / google - api - objectivec service . shouldFetchNextPages = YES ;
GTLQueryDrive query = [ GTLQueryDrive queryForFilesList ] ;
*
/ / queryTicket can be used t o track the status of the request .
GTLServiceTicket queryTicket =
*
[ service executeQuery : query
completionFlandler : A ( GTLServiceTicket ^ ticket , GTLDriveFileList
NSError error ) {
*
i f ( error == n i l ) {
completionBlock ( f i l e s . items , n i l ) ;
} else {
NSLog ( @ " An error occurred : %@ " , error ) ;
completionBlock ( n i l, error ) ;
}
}];
*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
Stay up-to-date on developing
for Google Apps
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