Image file is not viewing uploaded by s3

I am uploading image files using s3. But whenever I try to download using the URL as well as from the s3 console will download the image file. But, it will not visible to the image viewer. It just shows an incompatible file type.

myS3Function.uploadFile(request.body.fileName, request.files.myFileData, "image_folder").then(filename => {
 //success
})
const AWS = require('aws-sdk');

const s3 = new AWS.S3({
 region: process.env.REGION
});

exports.uploadFile  = (filename, data, folderName) => {
return new Promise((resolve, reject) => {
    const params = {
        Bucket: process.env.AWS_S3_BUCKET, 
        Key: folderName+'/'+filename,
        Body: data.data,
        ACL:'public-read',
        ContentType: "image/jpeg"
    };
    s3.upload(params, function(s3Err, data) {
        if (s3Err) reject(s3Err)
        console.log(`File uploaded successfully at ${data.Location}`)
        resolve(`${data.Location}`)

    });
});
}

I uploaded files using postman now as form data. I can see text files uploaded using this code correctly. Then why do images have the issue? Also, images and pdf actual file size is increased a little bit.

The image I am getting is showing the error It appears that we don’t support this file format.

I tried by replace the upload code to s3 with local file upload using express. The issue still exists.

I refer Upload image to s3, image broken AND File uploaded to s3 but it doesn't open(corrupted) but no use.

I have two questions

  1. Is there any way to fix this?

  2. If not, which is the best latest way I need to choose from the below?

    • Amplify s3 upload
    • Signed url upload
    • Or any other latest

Could you please share a ZIP of the codebase? It’d help me eliminate the various probable causes of the problem.

I uploaded it to the above link. I removed some company related data. Thank you

was this resolved?
if yes can you share how it was resolved?
Thank you!

Hi, is this issue resolved ? i am getting same issue

I fixed it by uploading files by signed URL and AWS will automatically store it and we can retrieve files in normal jpg format