anacronw / multer-s3

multer storage engine for amazon s3
MIT License
660 stars 190 forks source link

Filename not working #94

Closed damianbuttle closed 6 years ago

damianbuttle commented 6 years ago

I have been able to upload to my amazon S3 bucket, perfectly, but when I try and display the new file name in the confirmation, all that displays is undefined.

` var upload = multer({ storage: multerS3({ s3: s3, bucket: 'imagebucket', acl: 'public-read', metadata: function (req, file, cb) { cb(null, Object.assign({}, req.body)); }, key: function (req, file, cb) { console.log(file); cb(null, Date.now()+file.originalname); } }) })

app.post('/upload', upload.single('upload'), function(req, res, next) {
  res.send('Successfully uploaded ' + req.file.length + ' file!')
})`

and this is my form:

`

              <p>
                  <input type="file" name="upload"/>
              </p>

              <p></p>

              <p>
                  <input type="submit"/>
              </p>
          </form>`
LinusU commented 6 years ago

'Successfully uploaded ' + req.file.length + ' file!'

I think you meant to look at req.file.key instead of req.file.length?

damianbuttle commented 6 years ago

Perfect, thanks :-)