Node.js S3-uploader issue

2019-09-14 21:53发布

Trying to upload from node.js to Amazon S3 getting this error i spent all day to find an error no luck, image magic installed, app running on elastic beanstalk, previously installed on development server and code is working just fine when i move the application to aws its causing this error i checked all the dependencies its same as development server.

Node.js Log

    Upload data:tmp/c0005d84e41ec82b4f5ae2b1cbf1c3b8
{ [Error: Command failed: /bin/sh -c identify -format "name=
size=%[size]
format=%m
colorspace=%[colorspace]
height=%[height]
width=%[width]
orientation=%[orientation]
" tmp/c0005d84e41ec82b4f5ae2b1cbf1c3b8
/bin/sh: identify: command not found
]
  killed: false,
  code: 127,
  signal: null,
  cmd: '/bin/sh -c identify -format "name=\nsize=%[size]\nformat=%m\ncolorspace=%[colorspace]\nheight=%[height]\nwidth=%[width]\norientation=%[orientation]\n" tmp/c0005d84e41ec82b4f5ae2b1cbf1c3b8' }

S3 upload options

var client = new upload('XXX', {

    aws: {
     path: 'images/',
     region: 'us-east-1',
     acl: 'public-read',
     accessKeyId: 'XXX',
     secretAccessKey: 'XXXX'
   },

   cleanup: {
     versions: true,
     original: false
   },

   original: {
     awsImageAcl: 'private'
   },

   versions: [{
     maxWidth: 1040,
     format: 'jpg',
     suffix: '-large',
     quality: 80
   },{
     maxWidth: 780,
     suffix: '-medium',
     format: 'jpg',
     quality: 80
   }]
 });

Upload Script

app.post('/profile/upload', mupload.single('avatar'), function (req, res, next) {


    var data = req.file;
    console.log("Upload data:" + data.path);

    client.upload(data.path, {}, function(err, versions, meta) {
          console.log(err);
          console.log(meta);
          console.log("versions data:" + versions);
          versions.forEach(function(image) {
                    res.end(image.url);
          });


    });

});

1条回答
我只想做你的唯一
2楼-- · 2019-09-14 22:33

this is your problem: /bin/sh: identify: command not found

the program identify is not installed, you need to install imagemagick on the EB instance. In your .ebextensions/packages.config add

packages:
  yum:
    ImageMagick: []
查看更多
登录 后发表回答