One dilemma I am facing is with a form that allows users to upload files with any name. However, when trying to display this name as a download link later on, issues arise with characters like spaces being replaced by '%20' by AWS, leading to poor user experience.
To learn more: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
During the upload process, I use the following parameters
s3.upload(uploadParams, function(err, data) {
const uploadParams = {
Bucket: req.params.bucketname,
Key: req.headers.filepath,
Body: ""
};
For downloading, I utilize the following parameters
s3.getObject(bucketParams, function(err, data) {
const bucketParams = {
Bucket: req.params.bucketname,
Key: req.headers.filepath,
};
As someone new to AWS, I am uncertain of the best approach to tackle this issue. While attempting to use Content-Disposition
did not yield results, my next plan is to store the filename in my database alongside the file URL. This way, when retrieving the fileBody, I can display it using the previously saved filename.