daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HttpTransport httpTransport = new NetHttpTransport();
  2. JsonFactory jsonFactory = new JacksonFactory();
  3. AppIdentityCredential credential =
  4.    new AppIdentityCredential.Builder(Arrays.asList(DriveScopes.DRIVE)).build();
  5. // API_KEY is from the Google Console as a server API key
  6. GoogleClientRequestInitializer keyInitializer =
  7.    new CommonGoogleClientRequestInitializer("<my-service-account-key>");
  8. Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
  9.    .setHttpRequestInitializer(credential)
  10.    .setGoogleClientRequestInitializer(keyInitializer)
  11.    .setApplicationName("<my-service-account-name>").build();    
  12.  
  13. String pageToken = null;
  14. do {
  15.    StringBuilder query = new StringBuilder(
  16.                 "'" + folderId + "' in parents and mimeType != 'application/vnd.google-apps.folder' and trashed = false");
  17.    FileList result = service.files().list()
  18.       .setQ(query.toString())
  19.       .setSpaces("drive")
  20.       .setFields("nextPageToken, files(id, name)")
  21.       .setPageToken(pageToken).execute();
  22.    // do something
  23. } while (pageToken != null);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top