Search code examples
javaxmljsongoogle-drive-apidata-files

make a data file of google drive account using google drive api


I'am want to get all of my data in google drive into file (xml or json it's not so matter). the regular way to do it is like this:

Drive service = new Drive(somedata);
String fileName = service.get(fileId).execute().getTitle();

to get the file id, it's needed to do this:

Children.List request  = service.children().list(root);
ChildList children = request.execute();
String fileId = children.getItems().get(0).getId();

the problem is that the:

String fileName = service.get(fileId).execute().getTitle(); 

take very long time for each file.

and if I want to create a data file that contain all my data it's will take a lot of time.

I need the file name for the presentation of the file system of my google drive account.

anyone dealed with it and know waht to do?


Solution

  • Instead of children.list(root) do files.list(q='root' in parents, fields=nextPageToken, items/title). That way you get all of your titles in a single (paginated) fetch.

    NB. This is pseudo code. Look at the Java library for the exact syntax