将base64编码的图像上传到Node.js服务器无法工作



我正在使用MEAN.io,并试图上传一个base64编码的图像。

客户端,AngularJS:

          // Image we're going to send it out
          var base64Image = files[i];
          var file = {
            image: base64Image,
            type: type,
            filetype: extension,
            characterId: character._id
          };
          var newFile = new MediaSendBase64(file);
          newFile.$save(function(image) {
            if ( !image ) {
              console.log('ERROR IMAGE');
            }
            else {
              console.log('SUCCESS.');
              console.log(image);
            }
          });

服务器端,NodeJS,控制器:

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
exports.uploadBase64 = function(req, res, next) {
  var uploadPath  = path.normalize(process.cwd() + '/packages/characters/public/assets/uploads/'),
      data        = new Buffer(''),
      imgURL      = undefined,        // public URL to show the pic
      type        = undefined;

  // In case the '/uploads' directoy doesn't exist
  if( !fs.existsSync(uploadPath) ) {
    fs.mkdirSync(uploadPath, 0755);
  }

  // Decoding the base64 image
  var data = new Buffer(req.body.image, 'base64');
  // Creating the name for the file --> characterId + type + timestamp + extension
  var filename = req.body.characterId + '-' + req.body.type + '-' + new Date().getTime().toString() + '.' + req.body.filetype;
  // Writing the image to filesystem
  fs.writeFile(uploadPath + filename, data, function (err) {
    if ( err ) {
      console.log(err);
      return res.status(500).json({
        error: 'Cannot upload the image. Sorry.'
      });
    }
    console.log('SAVED ON HD');
    console.log('FINISHING');
    // Sending success response
    res.json({
      imgURL: imgURL,
      type: type
    });
  });
};

问题是存储在/uploads中的文件不起作用。我看不到图像。发送base64映像并将文件写入硬盘,但无法打开。

怎么了?有什么建议吗?

谢谢!

可能您正在尝试使用元数据保存文件。从而使得来自base64的解码数据无效。

我的意思是:

data:image/png;base64,iVBORw0KG....

数据:image/png;base64只是元,并没有使用base64进行编码,所以:

您需要将其从刺痛中剥离,然后解码,然后保存到磁盘。

我使用这个方便的功能:

function decodeBase64Image(dataString) {
  var matches = dataString.match(/^data:([A-Za-z-+/]+);base64,(.+)$/),
    response = {};
  if (matches.length !== 3) {
    return new Error('Invalid input string');
  }
  response.type = matches[1];
  response.data = new Buffer(matches[2], 'base64');
  return response;
}

来源:NodeJS写base64镜像文件

因此,我使用它的一个片段:

 var decodedImg = decodeBase64Image(imgB64Data);
 var imageBuffer = decodedImg.data;
 var type = decodedImg.type;
 var extension = mime.extension(type);
 var fileName =  "image." + extension;
 try{
       fs.writeFileSync(".tmp/uploads/" + fileName, imageBuffer, 'utf8');
    }
 catch(err){
    console.error(err)
 }

其中mime是伟大的节点mime-lib。npm安装mime。

如果您使用express文件上传,您可以执行此

routerApi.patch('/upload_gambar', (req, res) => {
    var file_data= req.files.upload_file_name.data;
    var base64Image = file_data.toString('base64');
}

如果你使用multer文件上传,你可以做这个

routerApi.patch('/upload_gambar', upload.single('upload_file_name'),(req, res) => {
    var file_data= req.file.buffer
    var base64Image = file_data.toString('base64');
}

Node js base64在读写这里的代码后将图像转换并上传到磁盘上。

var imgBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASgAAACrCAMAAADiivHpAAAA2FBMVEX////u7u7t7e1fORT39/f09PTx8fH6+vrz8/P+/v/+/vxeORRWKQD9//9RJABfORVaMQBdNg7TysNeNQhZLwBRIQBrSSrCt61WKgA9AADt6ORVJgCJcV5PHgA6AABXLwBEAABNGgCfjoCzpZrZ0szk4Nri29aSfGiXgnN/ZVBKEwC7raLVzMbx7ehjQSBZKgB4W0SqmYt1VzyejYBsSzFGCgDGvrcyAACZhnNzUDqCaE/l4+Tk2tH89PLOxLZ3WDpiQRh9ZEpuSyeomoePdl9jQCSVgGtbNBFOnm0VAAAgAElEQVR4nO1di2OiOBOPBUVAkPAQClqr4KuKFdvluo/u3X7f7d7//x99MwlYrOCjj233u83ttY1CmPyYTGYmkwkhrIg1LGcyq0hnrCLxr3hF5BV2Wa3OKw1WafBKnX+11RyvSLVCc3JJ21vNNXmlWWyuXtLcTyM1a478Buo3UL+B+lWAOvs3A3V23NO3e3ZWfPpZ8elnxaef7T69DKga1M6gOU1DoPCrs1qx7bPTSK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H5okX3jOPba56rbrz2473yl2EqkvmqabHMx9XZ714+y4wbQ7UH8KqW9rwhSbOwRUrQjU25owv4H6DdTPAOrJRnHp00uyfhzchFkio55DaplZUApUmVFc2IQkZ5Um23IFApcf2sQqIqvU5GKFn3UoFStyrbAjKW+bt9A81DZrgUi7befN1U5qTj7Q3EFSG9tt52/hZfSo043ip+pRR5L6TtN0/ws0899A/Qbq7YB64pL6/wdQT7IisPY493CxObLb3B6gDqVwOtHgqR0g9aBuUn52FS9bFbH6q6dUXri5n03qC6fpPmRpnvhSDxrFp63CHE1q2VApGcq/TZhdUn8D9Ruo30D9BupdA/U/BYxN4jSuinwAAAAASUVORK5CYII=';
var base64Data = imgBase64.replace(/^data:image/png;base64,/, "");
    fs.writeFile(uploadPath+"/out.png", base64Data, 'base64', function(err) {
    console.log(err);
    });
fs.readFileSync(base64Data, {encoding: 'base64'});

相关内容

  • 没有找到相关文章

最新更新