【问题标题】:How to upload files to google drive. Is it possible through Retrofit 2如何将文件上传到谷歌驱动器。是否可以通过改造 2
【发布时间】:2016-09-07 21:26:46
【问题描述】:

我必须将一些文件上传到我的 Google Drive 帐户。目前我正在使用下面的代码将文件上传到谷歌驱动器

 OutputStream outputStream = driveContents.getOutputStream();
                        addTextfileToOutputStream(outputStream);
                        MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                                .setTitle("testFile")
                                .setMimeType("text/plain")
                                .setDescription("This is a text file uploaded from device")
                                .setStarred(true).build();
                        Drive.DriveApi.getRootFolder(googleApiClient)
                                .createFile(googleApiClient, changeSet, driveContents)
                                .setResultCallback(fileCallback);

有没有使用 Retrofit 上传文件的方法。任何帮助都应该非常感谢并对我有帮助。

【问题讨论】:

    标签: android file-upload retrofit retrofit2 google-drive-android-api


    【解决方案1】:

    如何将文件上传到谷歌驱动器?

    这是Upload Quickstart for Drive。 Java 示例是here

    可以通过 Retrofit 2 实现吗?

    只要您能够进行 HTTP 访问,就可以使用 Google Drive API。您将使用 java.net.URL 类和 java.net.HttpURLConnection 类。 这是带有实际代码的link。别忘了要集成Drive平台,你需要先Setup it Up

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      相关资源
      最近更新 更多