如何在Google云端硬盘上保存流?

时间:2012-11-28 17:02:17

标签: google-app-engine google-drive-api

我的应用程序在google app引擎上运行,因此无法使用File。我想将其他网站上的pdf文件保存到谷歌驱动器,但得到IllegalArgumentException

file.setMimeType("application/pdf");
mediaContent = new InputStreamContent(file.getMimeType(),
                   url.openStream());

try {
    File result = getDrive().files().insert(file, mediaContent)
                .execute();
        return result.getId();
    } catch (Exception e) {
        e.printStackTrace();
    }

由于

1 个答案:

答案 0 :(得分:0)

查看Google Drive SDK文档,了解在App Engine上运行的完整Java示例应用程序,了解如何读取文件并将其保存到云端硬盘:

https://developers.google.com/drive/examples/java