Google驱动器导出非Google文档文件 [英] Google drive export non-google doc file
问题描述
$ b
String str =application / rft;
OutputStream outputStream = new ByteArrayOutputStream();
driveService.files()。export(fileId,str).executeAndDownloadTo(outputStream);
并且它正常工作,但是当我尝试导出 application / pdf
或 application / png
或者 application / jpeg
file我得到这个错误: p>
403 Forbidden
{
code:403,
errors:[{
domain:global,
message:Export only only Google Docs。,
reason:fileNotExportable
}],
消息:导出只支持Google文档。
}
我想知道是否有办法使用此文件的内容Java
提前致谢 a href =https://developers.google.com/drive/v3/reference/files/export =nofollow noreferrer> files.export
。但是当它下载除Google文档以外的文件(pdf,png和jpeg)时,请使用 files()。get()
。
您可以在此处。您还可以看到示例脚本。
编辑:
这是一个用于下载文件的示例脚本, Google文档。
字符串fileId =### file ID ###;
OutputStream out = new FileOutputStream(### output filename ###);
driveService.files()。get(fileId).executeMediaAndDownloadTo(out);
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.
Edit :
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);
这篇关于Google驱动器导出非Google文档文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!