File Metadata Microservice

FreeCodeCamp Backend Challenge 5

Full-stack microservice (really basic frontend in Pug/HTML) that takes a FormData object from a file upload form and returns the file size in bytes as part of a JSON response.

User Stories

  • I can submit a FormData object that includes a file upload
  • When I submit something, I will receive the file size in bytes within the JSON response

Code

// upload page
exports.upload = function (req, res) {
  res.render('filesize/upload')
}

// File Metadata Microservice - file upload result
exports.result =  function (req, res) {
  res.json({
    'filename': req.file.originalname,
    'size': req.file.size
  })
}

Demo

View this code live on Heroku