从用户Google云端硬盘获取服务器下载文件

时间:2016-06-26 06:15:06

标签: android google-drive-api google-drive-android-api

我正在开发一款Android应用,可让用户使用Google Drive Android API从Google云端硬盘上传文件。我没有让用户将文件下载到设备然后将其上传到我的服务器,而是希望生成一个下载链接,用户可以将其发布到服务器并让它直接从Google Drive API下载文件。

这有可能吗?我能想到的唯一方法就是让用户在应用程序和浏览器窗口中进行身份验证,但这对于看似非常常见的用例来说非常麻烦。

1 个答案:

答案 0 :(得分:0)

我想生成一个下载链接..并让它直接从Google Drive API下载文件。

这当然可行,我已经尝试过了。在Creating Direct Links From Drive上试用本教程。只需记下您的文件类型-doc,ppt,img等。和相应的文件ID。

For Google Docs files:
https://docs.google.com/document/d/FILE_ID/export?format=doc 
https://docs.google.com/document/d/FILE_ID/export?format=pdf

For Google Presentations files:
https://docs.google.com/presentation/d/FILE_ID/export/pptx 
https://docs.google.com/presentation/d/FILE_ID/export/pdf

For Google Spreadsheets files:
https://docs.google.com/spreadsheets/d/FILE_ID/edit?usp=sharing

这是我使用pptx格式直接下载的SS。

enter image description here