私は、ユーザーがGoogleドライブからドキュメントをダウンロードするためにポップアップを表示するJava-JSF Webアプリケーションを開発しています。取得したばかりのIDからGoogle Docを取得する
はそれを行うために、私はいくつかのJSコードがあります。
<script src="filepicker.js"></script>
<script>
function initPicker() {
var picker = new FilePicker({
apiKey: 'MY_API_KEY',
clientId: my_client_id,
buttonEl: document.getElementById('pick'),
onSelect : function(file) {
if (file.id) {
sendLinkToBean(file.id);
} else {
alert('Unable to download file.');
}
}
});
}
</script>
<a4j:jsFunction name="sendLinkToBean" action="#{gPPersonFormBean.downloadFile()}">
<a4j:param name="param1" assignTo="#{gPPersonFormBean.fileId}"/>
</a4j:jsFunction>
file.idは豆が到着するとG.DriveのAPIのように、私はそれを取得しよう:
public void downloadFile(){
try {
Drive driveService = getDriveService();
OutputStream outputStream = new ByteArrayOutputStream();
driveService.files().get(fileId) .executeMediaAndDownloadTo(outputStream);
} catch (IOException e) {
String mess = "downloadFile(): "
+ (e.getMessage()!=null?". "+e.getMessage():"")
+ (e.getCause()!=null?". "+e.getCause():"");
logger.error(mess);
}
}
しかし、私はFileNotFoundExceptionを取得します。
com.google.api.client.http.HttpResponseException: 404 Not Found
{
"error": {"theID"
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: 1tvnGWDCse4TFQwIvqEDTlvv2cebfs0C2JBtjTP5A42I.",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: theID."
}
}
これはなぜ起こっているのでしょうか? ありがとうございます。
EDIT:私はちょうどGoogleとファイルのリンクで与えられたものと受信したIDを比較していますが、まったく同じです。
EDIT 2:私がdriveService.files().list();
を実行すると、空のリストが返されます。
おかげで、それは、404ファイルを同じエラーを与えました見つからない – Aldeguer
@Aldeguerご迷惑をおかけして申し訳ありません。私は今あなたのEDIT2を見ました。ダウンロードしたいファイルがGoogleドライブにあるかどうか尋ねることはできますか? – Tanaike
はい、Google PickerとJSで作成したドライブのドキュメントから選択しています。私は両方とも、私が作成したファイルと仲間が作ったが、私と共有したファイルの両方を試しました。誰も働いていませんでした – Aldeguer