I am trying to export several files from Google drive using this code:
String str = "application/rft";
OutputStream outputStream = new ByteArrayOutputStream();
driveService.files().export(fileId, str).executeAndDownloadTo(outputStream);
and it works properly but, when I try to export an application/pdf
or application/png
or application/jpeg
file I am getting this error:
403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Export only supports Google Docs.",
"reason" : "fileNotExportable"
} ],
"message" : "Export only supports Google Docs."
}
I would like to know if there is a way to get this file's content using Java
Thanks in advance
Google Docs can download using files.export
. But when it downloads files (pdf, png and jpeg) except for Google Docs, please use files().get()
.
You can see the detail information at here. Also you can see the sample script.
This is a sample script for downloading files except for Google Docs.
String fileId = "### file ID ###";
OutputStream out = new FileOutputStream("### output filename ###");
driveService.files().get(fileId).executeMediaAndDownloadTo(out);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With