简体   繁体   中英

Google drive integration?

I want to create a app which fetch the files which stored in my drive account and shows in the publicly in app. In this i was successfully integrated the Drive API to my app but now how i can fetch the files that stored in my google drive account can any one help me.

Taken straight from the documentation :

You can open files programmatically using the DriveResourceClient.openFile() method or by allowing the user to select a file using a file selector activity created with the DriveClient.newOpenFileActivityIntentSender() method. The file contains a reference to the contents of the file, encapsulated in the DriveContents class, which provides access to read and write the underlying data. You can read the contents of a drive file by accessing an input stream of its contents by calling DriveContents.getInputStream().

To create a file, you can use either the DriveResourceClient.createFile method or the DriveClient.newCreateFileActivityIntentSender() method, which presents a dialog to the user that allows them to create the new file in their Drive.

For more information about how to work with files, see Working with File Contents. For more information about how to create files, see Creating Files

Also, you'll need the DriveID

Querying:

Query query = new Query.Builder()
                      .addFilter(Filters.eq(SearchableField.TITLE, "HelloWorld.txt"))
                      .build();

Task<MetadataBuffer> queryTask = getDriveResourceClient().query(query);

My suggestion would be place all the public files you want in a specific folder, say "public folder". Now what you have to do is change the permission of that folder into "share folder of type 'Anyone with Link' " Manually it looks like these:

在此处输入图片说明

Programatically, you would use permissions.create and set type to 'anyone'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM