📌  相关文章
📜  创建文件对象节点 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:35.639000             🧑  作者: Mango

代码示例1
var imagePath = path.join('/images/logo.png', 'logo.png');

  if (fs.statSync(imagePath)) {
     var bitmap = fs.readFileSync(imagePath);
     var bufferImage = new Buffer(bitmap);

     Magic = mmm.Magic;
     var magic = new Magic(mmm.MAGIC_MIME_TYPE);
     magic.detectFile(imagePath, function(err, result) {
          if (err) throw err;
          datas = [{"buffer": bufferImage, "mimetype": result, "originalname": path.basename(imagePath)}];
          var JsonDatas= JSON.parse(JSON.stringify(datas));
          log.notice(JsonDatas);
     });
 }