1

すべての Google ドライブ ファイルをダウンロードする必要があります。ダウンロードURLを取得し、このコードをpdf URLに使用するためにこれに従おうとし ています

file.getDownloadUrl() 

しかし、ダウンロードを呼び出したり、ストリームに変換したりすると、エラー 404: not found がスローされます。

私が行方不明になっている場所..いくつかの認証の問題またはそれ以上のもの.....ダウンロードのために私はこのように使用しています...

InputStream tempstream = Temp.downloadFile(service, file);

private static InputStream downloadFile(Drive service, File file) {
if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
  try {
      //download url is  : "https://doc-0s-9k-docs.googleusercontent.com/docs/securesc/6rpci9p5rgc1ards1udmrkv5oparm1a2/eoas3kt0uj6afg559kiugg3d6fftlere/1357740000000/06400000604443042302/18001816663358798513/0B2tdn0tkhMowTFVyRzYzaGhWeTQ?h=16653014193614665626&e=download&gd=true" 
    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;
}

}

downloadurl 助けてください...適切な認証でメソッドを呼び出すことができないと感じています....

4

1 に答える 1

0

次のことを確認する必要があります。

  1. あなたのサービスは承認されています
  2. ダウンロード URL は最新です (有効期限が切れているため)

そうでなければ、あなたのコードは正しいです。詳細については:

https://developers.google.com/drive/manage-downloads

于 2013-01-09T14:48:43.123 に答える