android - 从 Google Drive 下载文件的缩略图

标签 android google-drive-api

我可以使用以下代码从 Google 云端硬盘下载原始文件:

public static InputStream downloadFile(Drive service, File file)
            throws IOException {
        if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
            try {
                HttpResponse resp = service.getRequestFactory()
                        .buildGetRequest(new GenericUrl(file.getDownloadUrl()))
                        .execute();
                return resp.getContent();
            } catch (IOException e) {
                // An error occurred.
                e.printStackTrace();
                return null;
            }
        } else {
            // The file doesn't have any content stored on Drive.
            return null;
        }
    }

但在下载许多文件以添加到 GridView 时,连接似乎真的很低。

因此,我需要列出缩略图而不是原始文件,因为这样更利于连接。

请帮助我如何?

最佳答案

使用File.getThumbnail获取缩略图的方法或File.getIconLink获取图标链接。

关于android - 从 Google Drive 下载文件的缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17673356/

相关文章:

android - 如何在Gradle中使用Transform API?

php - 为什么 Google_Service_Drive 文件的属性只返回 null?

android - 通过访问 token 创建 GoogleCredential

android - 在云上备份 android 数据库?

android - 允许 Android SDK 通过网站搜索?

java - Android for循环在主线程中不起作用

android - 使用 navhost 时无法更改工具栏后退图标

android - 可以将文件从 Windows 应用程序直接写入 Android SD 卡吗?

python - 如何将从 Google Drive 下载的数据保存在文件中 - Python Drive API

google-drive-api - Drive API Children.list q 参数损坏