Search code examples
node.jsamazon-web-servicesamazon-s3aws-sdksharp

aws-sdk not deploying image to s3 bucket


I am using AWS Lambda to resize images in node.js by using aws-sdk andsharp

Issue I face is that it read file successfully and also apply resize operations but not put object after resize.

Even not giving any error also. I check cloud watch where everything is alright but image not place in resize folder.

It only create key folders but image not there

return Promise.all(_croppedFiles.map(_cropFile => {
            return  S3.putObject({
                Body: _cropFile.buffer,
                Bucket: dstBucket,
                ContentType: _cropFile.config.contentType,
                Key: dstKey
            }).promise()                        
        }))

Solution

  • There is actually no extension in the keyname, which makes it to be just a name and treated as a folder. provide your keyname as dstKey.jpeg or whatever extension you want , and set your content type to image/jpeg

    No matter what's the format of your input image , the output image will always be stored in "jpeg" format