如何使用DriveApi从谷歌驱动器下载选定的文件? [英] How to download selected file from google drive with DriveApi?

查看:155
本文介绍了如何使用DriveApi从谷歌驱动器下载选定的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Drive.DriveApi ,并通过使用DriveApi下载文件,但现在我升级了play-services版本,例如 com.google。 android.gms:play-services:11.8.0 so Drive.DriveApi.getFile(googleApiClient,driveId)不推荐使用,所以请建议任何解决方案它。如何从谷歌驱动器下载文件?

I am using Drive.DriveApi and by using DriveApi able to download file but now I have upgraded play-services version i.e. com.google.android.gms:play-services:11.8.0 so Drive.DriveApi.getFile(googleApiClient, driveId) is deprecated so please suggest any solution for it. How can download file from google drive?

我的工作代码

DriveId  driveId = (DriveId) data.getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);

 Log.e(TAG, driveId.getResourceId() + "");

 DriveFile driveFile = Drive.DriveApi.getFile(googleApiClient, driveId);
 driveFile.getMetadata(googleApiClient).setResultCallback(metadataRetrievedCallback);

但现在这个代码已被最新的更新弃用,所以请提出任何解决方案。

but now this code is deprecated with the latest update so please suggest any solution.

推荐答案

首先,我建议您检查下载文件文件,以了解底层概念。然后,为了在Android中实施,请检查 SO贴子

First I recommend you to check the Download Files docs in Drive API to know the underlying concepts. Then, for the implementation in Android, check this SO post.

这篇关于如何使用DriveApi从谷歌驱动器下载选定的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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