'How to correctly download file from AWS S3 in Express/React app

I have app where user can upload files to S3 storage. This works fine so far. After that I wanted to add download functionality so I followed each steps from some tutorials for the backend part. When I send download request from the client, the server send me object as a response but the file doesn't download. I'm beginner on this so I have no idea if I made any mistakes on backend code or it's correct but it need to do more thing. Thanks for help.

download: function (req, res) {
        const s3 = new aws.S3({
          region: "eu-central-1",
          accessKeyId: process.env.AWS_ACCESS_KEY,
          secretAccessKey: process.env.AWS_SECRET_KEY
        });
    
        var file = s3
          .getObject({
            Bucket: "my-files",
            Key: example-file
          })
          .createReadStream();
    
       file.pipe(res);
    }

Response [1]: https://i.stack.imgur.com/QeFaX.png



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source