Multer: How to saving base64 images with multer?

Created on 7 Aug 2017  路  3Comments  路  Source: expressjs/multer

I have an API uploading an image was encoded by base64. Then I upload this into my server. But I just read like a key/value in the body. How can Multer handle and saving an image encoded by base64?

Most helpful comment

I'm going to need more information to be able to help you. If the files are uploaded as base64 key/value pairs in the body you probably don't need multer at all. Just base64 decode the values (i.e. Buffer.from(req.body.myFile, 'base64') and then use the buffer, possibly writing it to a file (i.e. fs.writeFile(data, 'my-file.png')

All 3 comments

I'm going to need more information to be able to help you. If the files are uploaded as base64 key/value pairs in the body you probably don't need multer at all. Just base64 decode the values (i.e. Buffer.from(req.body.myFile, 'base64') and then use the buffer, possibly writing it to a file (i.e. fs.writeFile(data, 'my-file.png')

Yes, you're right. I made it as you told and success. Thanks

Multer is cool when your uploading to amazon s3 right?

Was this page helpful?
0 / 5 - 0 ratings