1
Google 드라이브 파일의 리소스 URL에 accesstoken을 사용하여 아약스 GET 요청을 보내는 자바 스크립트 앱이 있습니다. 내가 가져온 응답은 모든 파일 일 수 있습니다 (첨부 파일/크기 100MB). 내 Ajax 호출에서 Content-Type 및 Content-Disposition을 쉽게 감지 할 수 있지만 일단 응답에 파일이 포함되어 있으면 브라우저에서 파일을 어떻게 다운로드해야합니까?아약스에서 Google 드라이브 파일을 다운로드하십시오.
$.ajax({
url: "https://www.googleapis.com/drive/v3/files/" + fileid + "?alt=media",
method: 'GET',
headers:
{
'Authorization': 'Bearer' +accessToken
},
success: function (response, status, request) {
var disp = request.getResponseHeader('Content-Disposition');
if (disp && disp.search('attachment') != -1) {
alert('We have an attachment to download');
}
var type = request.getResponseHeader('Content-Type');
alert('Attachment is of type' + type);
}
});
});
이제 어떻게하면 아약스 요청을 사용하여 응답 파일을 다운로드 할 수 있습니까?