Search in sources :

Example 41 with File

use of com.google.api.services.drive.model.File in project local-data-aragopedia by aragonopendata.

the class GoogleDriveAPI method download.

private void download(String path, File file) throws IOException {
    if (file.getShared()) {
        String downloadUrl = file.getExportLinks().get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        HttpResponse resp = drive.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl)).execute();
        InputStream input = resp.getContent();
        java.io.File f = new java.io.File(path + java.io.File.separator + file.getTitle() + "." + Prop.formatConfig);
        FileUtils.copyInputStreamToFile(input, f);
    }
}
Also used : InputStream(java.io.InputStream) HttpResponse(com.google.api.client.http.HttpResponse) GenericUrl(com.google.api.client.http.GenericUrl) File(com.google.api.services.drive.model.File)

Aggregations

File (com.google.api.services.drive.model.File)41 Test (org.junit.Test)19 IOException (java.io.IOException)17 HashMap (java.util.HashMap)9 FileList (com.google.api.services.drive.model.FileList)7 ParseException (java.text.ParseException)7 ArrayList (java.util.ArrayList)7 FileContent (com.google.api.client.http.FileContent)6 GeneralSecurityException (java.security.GeneralSecurityException)6 GenericUrl (com.google.api.client.http.GenericUrl)4 HttpResponse (com.google.api.client.http.HttpResponse)4 Permission (com.google.api.services.drive.model.Permission)4 User (com.google.api.services.drive.model.User)4 InputStream (java.io.InputStream)4 UserRecoverableAuthIOException (com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException)3 DateTime (com.google.api.client.util.DateTime)3 ParentReference (com.google.api.services.drive.model.ParentReference)3 Comment (com.google.api.services.drive.model.Comment)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2