JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q26505F
  • License Apache License 2.0

http-body解析

Package Exports

  • fc-body
  • fc-body/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fc-body) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

HttpBody解析类库--fc-body

  • Http请求体解析,支持多文件,支持类型限制,body大小限制,简单优雅,快速高效

如何安装:

npm install fc-body

如何使用:

//  promise对象
const fc_body = require('fc-body');
let body = new fc_body({isAutoSaveFile: true, savePath: __dirname+"/upload"});
let post = '';
http.createServer(async (req,res) => {
    try {
       post = await body.getBody(req);
       console.log(post);
    } catch (e) {
       console.log(e);
    }
});

option参数:

参数 类型 默认 备注
type string 限制上传类型,多个用,号分割(不区分大小写),为空不限制
isAutoSaveFile bool false 是否保存文件
savePath string os.tmpdir() 保存目录
minSize int,float 0 上传文件的最小M数
maxSize int,float 5 上传文件的最大M数
errorMsg object {'TIMEOUT':'POST超时','UNDERSIZE':'数据过小','OVERSIZE':'数据过大','NOTALLOWEDTYPE':'不允许的类型'} 错误消息

使用参考

更多使用demo请看这里 >>> 戳这里

作者备注

  • 如果发现问题,欢迎向我反馈,毕竟一个人测试有限,会有注意不到的地方。
  • 作者QQ:1102952084
  • 作者博客:blog.lovefc.cn