Google Drive api Android下载Google文档文件 [英] Google Drive api Android download Google doc file

查看:154
本文介绍了Google Drive api Android下载Google文档文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Google驱动器下载文件。我在Android上使用JAVA API,因为Google说它提供了对Google Drive的更多控制权。

I am trying to download files from Google drive. I am using the JAVA API for on android since Google says it provides more control over Google Drive.

到目前为止,我可以下载文件,但无法下载Google文档文件。

So far I can download files, but I cannot download Google doc files.

我假设这是因为,为了下载Google文档,需要先将其转换为PDF / Word / HTML,然后才能下载它,大小是未知/ 0。

I assume this is because in order to download a Google doc file it needs to be converted to PDF/Word/HTML before I can download it and the same reason why the size is unknown/0.

所以我的问题是如何将Google文档转换为word文档并下载它?

So my question is how can convert a Google doc to a word document and download it?

推荐答案

我假设您正在查找要导出的Doc类型的查询URL

I assume you are looking for URL to query for exporting Doc type

url:'https://www.googleapis.com/drive/v3/files/' + fileId + '/export?mimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document'
method: GET
Content-Type: 'application/json'
Authorization: 'Bearer <Your oauth token>'

改变mimeType参数根据允许的m所需的值ime类型此处
响应正文包含导出的文档。
您可以使用以下wget命令测试参数。它将在result.doc中导出文档

Alter mimeType parameter your required value as per allowed mime types here. Response body contains the exported document. You can test parameters with following wget command. It will export document in result.doc

wget  --header="Authorization: Bearer <your Oauth token>"  --header="Content-Type: application/json" --method=GET  'https://www.googleapis.com/drive/v3/files/{FileID}/export?mimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document' -O result.doc

这篇关于Google Drive api Android下载Google文档文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆