사용자가 Google 드라이브에서 문서를 다운로드하도록 선택할 수 있도록 팝업을 표시하는 Java - JSF 웹 응용 프로그램을 개발 중입니다.방금 검색 한 ID에서 Google 문서 가져 오기
는이를 위해 좀 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와 파일의 링크를 비교 한 결과는 완전히 동일합니다.
편집 2 : 만약 내가 driveService.files().list();
이면 빈 목록을 반환합니다.
감사합니다,하지만이 같은 오류를 준, 404 파일 찾지 못했습니다 – Aldeguer
@Aldeguer 불편을 끼쳐 드려 죄송합니다. 지금 EDIT2를 봤어. 다운로드하려는 파일이 Google 드라이브에 있는지 여부를 묻는 질문을 할 수 있습니까? – Tanaike
예, Google 피커 및 JS로 만든 드라이브의 문서에서 선택합니다. 나는 저에게 창조 된 파일 하나와 친구에 의해 창조되었지만 나와 공유 된 파일을 모두 시험해 보았습니다. 아무도 일하지 않았습니다. – Aldeguer