0
....は私がAWS S3バケット「upload.array( 『写真』、3)」次のコードで表すと何
私のhtmlコードに画像をアップロードするmulter-S3を使用して、完全にかすかなよ。 (簡略化のために減少したコード)
<form action="/upload" method="POST">
<input type="file" name="pic" id="pic" accept="image/*">
<input type="submit">
</form>
私expressjsコード
AWS.config.update({
accessKeyId: "xxxxxxxxxxxxx",
secretAccessKey: "yyyyyyyyyy",
"region": "zzzzzzzzz" ,
signatureVersion: 'v4'
});
var s3=new AWS.S3();
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'imgcontainer',
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, Date.now().toString())
}
})
})
app.post('/upload', upload.array('photos', 3), function(req, res, next) {
res.send('Successfully uploaded ' + req.files.length + ' files!')
})
出力:
Cannot read property 'length' of undefined
あなたのお返事ありがとうございます "upload.array(" pic "、3)" ...次に3はどういう意味ですか..... –
[The documentation](https://github.com/expressjs/multer #arrayfieldname-maxcount)はそれを説明しています。それは 'maxCount'パラメータです(そのファイルフィールド名の最大ファイル制限を強制します)。 – mscdex
同じエラー写真を写真に変更した後でも、 '定義されていない'長さ 'のプロパティを読み取れません.....ごめんなさい –