2017-04-09 12 views
0

このモジュールhttps://www.npmjs.com/package/s3-uploaderを使用しようとしていますが、実装方法がわかりません。どのように私のルータにPOSTを行うには?AWS S3 Image Uploader with NodeJSおよびs3-uploaderモジュール

.post('/upload', ensureAuthenticated, (req, res, next) => { 

let files = req.files; 

let client = new Upload(process.env.AWS_BUCKET_NAME, { 
    aws: { 
    path: process.env.AWS_BUCKET_PATH, 
    region: process.env.AWS_BUCKET_REGION, 
    acl: 'public-read' 
    }, 

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

    original: { 
    awsImageAcl: 'private' 
    }, 

    versions: [{ 
    maxHeight: 1040, 
    maxWidth: 1040, 
    format: 'jpg', 
    suffix: '-large', 
    quality: 80, 
    awsImageExpires: 31536000, 
    awsImageMaxAge: 31536000 
    },{ 
    maxWidth: 780, 
    aspect: '3:2!h', 
    suffix: '-medium' 
    },{ 
    maxWidth: 320, 
    aspect: '16:9!h', 
    suffix: '-small' 
    },{ 
    maxHeight: 100, 
    aspect: '1:1', 
    format: 'png', 
    suffix: '-thumb1' 
    },{ 
    maxHeight: 250, 
    maxWidth: 250, 
    aspect: '1:1', 
    suffix: '-thumb2' 
    }] 
}); 

client.upload(files.file.path, {}, function(err, versions, meta) { 
    if (err) { throw err; } 

    versions.forEach(function(image) { 
    console.log(image.width, image.height, image.url); 
    // 1024 760 https://my-bucket.s3.amazonaws.com/path/110ec58a-a0f2-4ac4-8393-c866d813b8d1.jpg 
    }); 
}); 
} 

.postの内側に私がコピーされ、NPMのウェブサイトでは、彼らが持っているコードを貼り付けし、鉱山値に変数の値を変更しました。

私はこのエラーを取得しています:

Error: Command failed: identify -format "name= 
size=%[size] 
format=%m 
colorspace=%[colorspace] 
height=%[height] 
width=%[width] 
orientation=%[orientation] 
" /images/logo.png 
/bin/sh: identify: command not found 

    at ChildProcess.exithandler (child_process.js:206:12) 
    at emitTwo (events.js:106:13) 
    at ChildProcess.emit (events.js:191:7) 
    at maybeClose (internal/child_process.js:877:16) 
    at Socket.<anonymous> (internal/child_process.js:334:11) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at Pipe._handle.close [as _onclose] (net.js:498:12) 

を私はこのスレッドの関連ではなく、完全に役立つトピックを見つけました:ここ Node.js S3-uploader issue

答えて

0

は、ソリューションです:

唯一のものローカルホストにimagemagickをインストールしていました。

端末でこれを実行する必要があります。

cd $HOME

brew install imagemagick

それはあなたがバージョンや詳細

brew info imagemagick

あなたはbrewを持っていけない場合、あなたはそれをインストールする必要がありますを参照するために、これを実行することができます終了します。

ありがとうございます

関連する問題