本文介绍了谷歌驱动器执行力度,以Android应用程序和下载从谷歌驱动器的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

驱动器快速启动应用程序示例适用于只能从Android设备上传文件到用户帐户。我想从GDrive的文件下载到Android应用程序。任何帮助将AP preciated。

Drive Quick-start App example works for only uploading files from Android Device to user account. I want to download the files from Gdrive to android app. any help will be appreciated.

我想确切扭转这种演示示例过程https://developers.google.com/drive/quickstart-android (从GDrive的下载)

I want exact reverse process of this Demo example https://developers.google.com/drive/quickstart-android (download it from Gdrive)

推荐答案

有两个步骤,从驱动器下载文件的内容。首先,检索该文件的元数据和一个downloadUrl为文件:

There are two steps to download file contents from Drive. First, retrieve the file's metadata and a downloadUrl for the file:

// retrieve metadata
File file = drive.files().get(fileId).execute();

和,使经过身份验证的请求将downloadURL:

And, make an authenticated request to the downloadUrl:

// download contents a
GenericUrl url = new GenericUrl(file.getDownloadUrl());
HttpResponse response = drive.getRequestFactory().buildGetRequest(url).execute();
String contents = new Scanner(response.getContent()).useDelimiter("\\A").next();

这篇关于谷歌驱动器执行力度,以Android应用程序和下载从谷歌驱动器的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 01:15