简体   繁体   中英

Can't properly parse multipart/form-data inside Azure functions using Node.js

I'm trying to parse multipart/form-data from my Azure function writing in Node.js, but the context.req.body is not binary, and if I try to parse a PDF (for example) it will loose information. Is there a way to bypass it? I've searched a LOT and it seems that this is a knowing issue.

module.exports.handler = (context) => {
  context.info(context.req.body) // This is a string, not a binary
}

I've also tried to change the dataType to binary , inside the functions.json, but it still keeps going as string, so I guess this is a bug.

Indeed it's a known issue, see Multipart/form-data processing via HttpTrigger doesn't work for Azure Functions .

The suggested workaround for now is to use Base64 encoding, as described in Image uploading with Azure Functions node.js and Angular 4 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM