Using server side logic, I have an ExpressJS API endpoint for getting a file from an S3 bucket. Basically, it sends back the file like this:
const downloadFileFromS3Bucket = async (req, res, next) => {
try {
// ...
await s3.getObject(options, (err, data) => {
// ...
if (data) {
res.send(Buffer.from(data.Body));
}
});
} catch (error) {
// ...
}
};
It works as expected (I use postman to check on it).
Now, I want to download that file using a ReactJS app. If, for instance, I use axios to do a request to that endpoint, I get the binary code as shown here as the response:
How could I achieve to download the file that is sent to me as you can see on the data property?
Since my api method is a GET method, I also tried using a simple:
window.open('url');
But I have server verification by Bearer token implemented and it won't work.