简体   繁体   English

Android使用Google Play服务将文本文件从sdcard上传/下载到Google云端硬盘

[英]Android upload/download text files from sdcard to Google Drive with Google Play Services

I want to implement Google Drive upload/download txt file to my Android app using Google Play Services, but I don't find a right way to do it. 我想使用Google Play服务在我的Android应用中实现Google Drive的上传/下载txt文件,但是我找不到正确的方法。

In dropbox is very easy: 在保管箱中非常简单:

File file = new File("working-draft.txt");
FileInputStream inputStream = new FileInputStream(file);
Entry response = mDBApi.putFile("/magnum-opus.txt", inputStream,
                            file.length(), null, null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + response.rev);

But for Google Drive with Google Play Services I have not found a simple way like that. 但是对于带有Google Play服务的Google云端硬盘,我还没有找到一种简单的方法。 Do you know how to? 你知道怎么?

By the way, I would like to use my own credentials (google service account) instead an user account, what is the way to implement it with Google Play Services? 顺便说一句,我想使用自己的凭据(Google服务帐户)而不是用户帐户,通过Google Play服务实现该身份的方式是什么?

Thanks in advance 提前致谢

Take a look here , it does everything you've mentioned. 在这里看看 ,它可以完成您提到的所有内容。 I don't know about the 'simple' requirement, though. 我不知道“简单”的要求。 Or go through the official DEMO code here . 在此处查看官方的DEMO代码 But it is definitely not a 'two-liner' endeavor. 但这绝对不是“两线”的努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM