@Public()
@Get('phone/recording/:id')`Preformatted text`
async redirectToAudioFile(
@Res() res: express.Response,
@Req() req: express.Request,
@Param('id') id: string,
) {
console.log('id', id);
try {
console.log('in try....');
const audioUrl = this.zoomService.getRecordingAudioUrl(id);
console.log('audioUrl', audioUrl);
const { access_token: accessToken } =
await this.zoomService.getAuthToken();
if (!accessToken) {
console.error('Access token is missing or invalid');
return res.status(401).send('Unauthorized');
}
const downloadResponse: AxiosResponse = await axios?.get(audioUrl, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
responseType: 'arraybuffer', // Set the responseType to 'arraybuffer' for binary data
});
// res.setHeader('Content-Type', 'audio/mp3');
console.log('res.headers', downloadResponse);
return downloadResponse
} catch (error) {
console.log('catch...........');
console.log('error', error);
}
}
and this is my res.headers
[Object: null prototype] {
'access-control-allow-origin': '*',
'content-security-policy': "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests",
'cross-origin-opener-policy': 'same-origin',
'cross-origin-resource-policy': 'cross-origin',
'origin-agent-cluster': '?1',
'referrer-policy': 'no-referrer',
'strict-transport-security': 'max-age=15552000; includeSubDomains',
'x-content-type-options': 'nosniff',
'x-dns-prefetch-control': 'off',
'x-download-options': 'noopen',
'x-frame-options': 'SAMEORIGIN',
'x-permitted-cross-domain-policies': 'none',
'x-xss-protection': '0',
authorization: 'Bearer token',
'content-type': 'audio/mp3',
'content-disposition': 'attachment; filename=audio.mp3'
}
don’t get any error
download response as a undefned what did I change to download phone recording in postman