Я пытаюсь добавить responseType, но файл всегда поврежден:
async downloadFromDrive(accountId: string, fileName: string, partNumber): Promise<boolean> {
return new Promise((resolve,reject)=>{
gapi.load('client:auth2', () => {
return gapi.client.init({
apiKey: this.API_KEY,
clientId: this.CLIENT_ID,
discoveryDocs: this.DISCOVERY_DOCS,
scope: this.SCOPES
}).then(() => {
this.googleAuth = gapi.auth2.getAuthInstance();
this.googleAuth.signIn().then(() => {
gapi.client.setToken({access_token: this.cookieService.get(accountId)});
gapi.client.drive.files.get({
fileId: fileName,
/* alt: 'media'*/
alt: 'media',
/* mimeType:'image/jpeg'*/
}).then(res => {
let header= new HttpHeaders({
'Authorization' : 'Bearer ' + this.cookieService.get(accountId),
'responseType' : 'arraybuffer'
});
this.http.get(res.result.webContentLink, { responseType: 'arraybuffer', headers: header} ).subscribe(res => {console.log(res);
/*resolve()*/});
console.log('download',res)
let blob: Blob = new Blob([res.body],{ type:'mimeType'})
this.sortedFiles[partNumber] = blob;
console.log('res-body')
resolve()