zoukankan      html  css  js  c++  java
  • node.js 接收上传的文件

    //limit 最大限制

    app.use("/record/:where/:id", bodyParser.raw({"limit":"50mb"}), function (req, res, next) {
    console.log("YES====");

    let where = req.params.where;
    let id = req.params.id;
    //console.log("id==="+id);
    let file = "";

    let dirpath = "/Users/tmp/";

    let dirname = "remote"+id+".webm";

    let dirname2 = "local"+id+".webm";
    //判断文件夹是否存在
    if (!fs.existsSync("/Users/tmp")) {
    fs.mkdirSync("/Users/tmp");
    }

    if (where === "remote") {
    file = dirpath+dirname;
    } else if (where === "local") {
    file = dirpath + dirname2;
    }else{
    return;
    }
    fs.writeFile(file, req.body, "binary", function (err) {
    if (err) {
    console.log("localBlobs fail", err);
    } else {
    console.log("localBlobs success");
    }
    });

    });

  • 相关阅读:
    在线心理测试脚本
    素数
    设置层叠效果
    年轻,无权享受...
    Unity3D之预设
    Json解析类
    php 正则表达式
    php 字符串处理
    php 基础语法
    SQL 函数
  • 原文地址:https://www.cnblogs.com/fengyifengceaser/p/7366083.html
Copyright © 2011-2022 走看看