【问题标题】:Downloaded file with Google Drive API. Can't find it anywhere使用 Google Drive API 下载的文件。在任何地方都找不到
【发布时间】:2016-08-01 09:37:40
【问题描述】:

我正在尝试使用 google drive api 下载文件。该代码没有错误,但我无法在任何地方找到该文件。 这是代码

String fileId = "...";
  OutputStream outputStream = new ByteArrayOutputStream();

  try {
    service.files().export(fileId, "text/csv")
              .executeMediaAndDownloadTo(outputStream);
} catch (IOException e) {
    System.out.println("Ceva nu a mers bine");
    e.printStackTrace();
}

    System.out.println(outputStream == null);

有什么想法吗?

【问题讨论】:

    标签: java google-drive-api


    【解决方案1】:

    根据example in Google documentation,我没有看到您的代码有任何错误。

    String fileId = "1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo";
    OutputStream outputStream = new ByteArrayOutputStream();
    driveService.files().export(fileId, "application/pdf")
            .executeMediaAndDownloadTo(outputStream);
    

    确保您使用的是您要下载的特定文件的正确fileId

    您可以查看以下链接:How to get Google Drive file IDHow to download a file from google drive using drive api java?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      相关资源
      最近更新 更多