Multer: How to change encoding type

Created on 8 Oct 2015  路  6Comments  路  Source: expressjs/multer

i'm uploading file through multer. i got an object after upload file as follows
{ fieldname: 'file',
originalname: 'follow-facebook.png',
encoding: '7bit',
mimetype: 'image/png',
destination: 'public/uploads',
filename: '5a655f198bd117d0a348300f3c028654',
path: 'public\uploads\5a655f198bd117d0a348300f3c028654',
size: 1320 }

here i want to change encoding to 'base64' instead '7bit', is it possible to change encoding to base64

Most helpful comment

Do you mind posting the solution for others to learn from?

All 6 comments

That is the encoding that the webbrowser used to send the file, you can't change it. If you want to have your data in base64 than you'll have to apply that transformation after the file has been uploaded.

i found a solution for my question. Thank you.

Do you mind posting the solution for others to learn from?

@92iruhd-hsetir 0_0...dude this is an open source community, the least you can do is sharing your findings.

@92iruhd-hsetir Do you mind sharing the fix that you found?

The following code should be the point:

if (header['content-transfer-encoding'])
        encoding = header['content-transfer-encoding'][0].toLowerCase();
      else
        encoding = '7bit';

So add content-transfer-encoding in request header will change encoding type

Was this page helpful?
0 / 5 - 0 ratings