后断开应用谷歌云端硬盘Android API仍返回成功的结果,但不上传文件 [英] After disconnecting app Google Drive Android API still returns successful results, but doesn't upload file

查看:138
本文介绍了后断开应用谷歌云端硬盘Android API仍返回成功的结果,但不上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌云端硬盘Android API(如谷歌Play的一部分服务)将文件上传到云。

I'm using Google Drive Android API (as part of Google Play Services) to upload files to cloud.

要连接的客户端我用下面的code(简体):

To connect client I'm using following code (simplified):

apiClient = new GoogleApiClient.Builder(context)
            .addApi(Drive.API)
            .setAccountName(preferences.getString("GOOGLE_DRIVE_ACCOUNT", null))
            .build();

ConnectionResult connectionResult = apiClient.blockingConnect(SERVICES_CONNECTION_TIMEOUT_SEC, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
    throw new ApiConnectionException(); //our own exception
}

要上传我用下面的东西code(简体)文件:

To upload file I'm using something following code (simplified):

DriveApi.ContentsResult result = Drive.DriveApi.newContents(apiClient).await();
if (!result.getStatus().isSuccess()) {
    /* ... code for error handling ... */
    return;
}

OutputStream output = result.getContents().getOutputStream();
/* ... writing to output ... */

//create actual file on Google Drive
DriveFolder.DriveFileResult driveFileResult = Drive.DriveApi
            .getFolder(apiClient, folderId)
            .createFile(apiClient, metadataChangeSet, result.getContents())
            .await();

一切正常,除了一个特定的用户案例。当用户从关联的应用(使用谷歌设置应用程序)中删除我们的应用程序这个code仍返回所有调用成功的结果。虽然文件是永远不会上传到谷歌驱动器。

Everything works as expected except for one particular user case. When user removes our app from "Connected apps" (using Google Settings application) this code still returns successful results for all invocations. Although file is never uploaded to Google Drive.

连接到谷歌播放服务也成功了。

Connection to Google Play Services also succeeds.

它是API的一个bug,或者可以以某种方式检测到用户断开连接应用程序?

Is it a bug of API or it can be somehow detected that user disconnected the application?

推荐答案

我不知道里面的API /输出,但是这个页面可以帮助的 https://support.google.com/drive/answer/2523073?hl=en 。我会仔细检查accounts.google.com页面,并验证所有被删除权限。这不会解决API的行为,但至少可以验证权限。

I don't know the API inside/out, however this page may help https://support.google.com/drive/answer/2523073?hl=en. I would double check the accounts.google.com page and verify that all permissions are being removed. This won't solve the api behaviour but at least you can verify the permissions.

这篇关于后断开应用谷歌云端硬盘Android API仍返回成功的结果,但不上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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