0

I'm trying to upload image to s3 bucket with some image preprocess like width,height and so on . My code as follows

html

 <form action="/upload" method="POST" enctype="multipart/form-data">
 <input type="file" name="pic" id="pic" class="pic" accept="image/*">
 <input type="submit">
 </form>

nodejs

var s3=new AWS.S3();

var upload = multer({
 storage: imager({
    dirname: 'avatars',
    bucket: 'patientimg',
    accessKeyId: 'xxxxxxxxxx',
    secretAccessKey: 'yyyyyyyyyyy',
    region: 'zzzzzz',
    signatureVersion: 'v4',
    filename: function (req, file, cb) {  
              cb(null, Date.now())                
     },                                    
     gm: {                                  
      width: 200,                         
      height: 200,
      options: '!',
      format: 'png'                       
     },
    s3 : {                                
    Metadata: {                        
    'acl': 'public-read'              
   }
  }

})
});


 app.post('/upload', upload.array('pic', 1), function(req, res, next){ 
 console.log(req.files); // Print upload details
 res.send('Successfully uploaded!');
 }); 

output as follows

Successfully uploaded!

but file size is "zero"

V Abinaya
  • 85
  • 1
  • 8
  • Search a little on net and you will hit this - https://stackoverflow.com/questions/26533245/the-authorization-mechanism-you-have-provided-is-not-supported-please-use-aws4 – Amit Yadav Jun 07 '17 at 15:07
  • I have tried that already but file size is zero, I have updated my question @Aky_0788 – V Abinaya Jun 07 '17 at 15:16

1 Answers1

0

Also Set crop.

gm: {                                 
    width: 360,                        
    height: 700,
    format: 'png',                      
    **crop: {
      width: 1000,
      height: 1000,
      x: 0,
      y: 0,
    },**
 },

And try to remove ! in options and see the difference between two images.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145