My Angular 1 application saves files to S3 and allows for a wide variety of files types.
When I retrieve the objects I use the following code:
export function show(req, res) { const s3 = new aws.S3(); const s3Params = { Bucket: S3_BUCKET, Key: req.query.key + '' }; res.attachment(req.query.key + ''); var fileStream = s3.getObject(s3Params).createReadStream(); fileStream.pipe(res); } I would like to open the received file on the client in a new window (just like on the AWS console) but I can't figure out how to go about it.
For example on the client side does not work at all:
.then( (data) => { var file = new Blob([data], {type: 'application/pdf'}); var fileURL = URL.createObjectURL(file); window.open(fileURL); } ) I really don't understand how the concept of data streams works.