How does nodejs handle post images to put them into /public/images inside?

  node.js, question

Novice nodejs, express.

The mobile side wants to use okhttp to directly post the picture file. Is there any method for nodejs to directly receive and store it?

I have tried Base64 upload before, and then to nodejs decode. I feel that a picture without text should not be so complicated.

express

Form adds this:enctype="multipart/form-data"

input(type="file")

Quote

var multiparty = require('connect-multiparty')
 var multipartMiddleware = multiparty();

Routing
app.post(‘/movie/save’,multipartMiddleware,Movie.savePoster,Movie.save)

exports.savePoster = function(req, res, next) {
 var posterData = req.files.uploadPoster
 var filePath = posterData.path
 var originalFilename = posterData.originalFilename
 
 if (originalFilename) {
 fs.readFile(filePath, function(err, data) {
 var timestamp = Date.now()
 var type = posterData.type.split('/')[1]
 Varposter = timestampplus'.' plus type
 * *//Save files to a specific directory * *
 Varnewpath = path.join (_ _ dirname,' ../../','/file/images/'plus poster)
 
 fs.writeFile(newPath, data, function(err) {
 //customize
 req.poster = poster
 next()
 })
 })
 bracket
 else {
 next()
 bracket
 bracket
 
 Finally, you can refer to the chapter video on uploading posters in http://www.imooc.com/learn/197, which is out of date, and the following chapter has upgrade methods.