David Lavelle
David Lavelle

Reputation: 41

Google Drive SDK - JavaScript : How to list SHARED FILES (not shared with me)

I'm looking for a way of finding a list of a user's shared files on google drive sdk using JavaScript.

Important: I am not looking for a list of files that are 'shared with me'.

What I have at the moment lists the files 'shared with me' and I'm wonder if there is a way of changing the 'sharedWithMe' query string parameter, to list the files that I have shared??

// Load the API and make an API call.  Display the results on the screen.
function makeApiCall() {
    // Load drive
    gapi.client.load('drive', 'v2', function() {
        // Request files (q is query string, to filter files)
        var request = gapi.client.drive.files.list ( {'maxResults': 200,'q':"trashed=false and sharedWithMe"} );

Any help would be great, thanks.

Dave

Upvotes: 1

Views: 920

Answers (2)

David Lavelle
David Lavelle

Reputation: 41

The answer is:

List the email address of the user you have shared files with in the 'readers' parameter in the q query string. (Note: 'readers' is a collection of users who have permission to view the file)e.g.:

// Check if recipient is in list of readers
var request = gapi.client.drive.files.list ( {'[email protected]' in readers"} );

Thanks!

Dave

Upvotes: 2

Jay Lee
Jay Lee

Reputation: 13528

If you're looking for all owned, shared files without knowing who they are shared with, you'd need to use a search query of 'me' in owners and then further filter down the list based on which returned files have shared: true set.

Upvotes: 2

Related Questions