简体   繁体   English

Sails.js如何将base64编码的图像转换为图像并将其存储在磁盘中?

[英]Sails.js how to convert a base64-encoded to image and store it in disk?

I'm trying to convert the base64-encoded to image but it doesn't work 我正在尝试将base64编码的图像转换为图像,但是它不起作用

var base64Data = req.rawBody.split(',')[1];
    require("fs").writeFile("out.png", base64Data, 'base64', function(err){
        if(err){
            console.log('err');
        }

I got it working by request fs 我通过请求fs工作

var request = require('fs');

before use in controller 在控制器中使用之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在sails.js 或通常在服务器端JavaScript 中将图像转换为base64 编码的数据URL? - How do I convert an image to a base64-encoded data URL in sails.js or generally in the servers side JavaScript? 如何下载 base64 编码的图像? - How to download a base64-encoded image? IPFS:base64 编码的图像未显示为图像 - IPFS: base64-encoded image not showing as image 在Javascript中将PDF转换为Base64编码的字符串 - Convert PDF to a Base64-encoded string in Javascript 上传到Google云端硬盘-如何使用base64编码的图像或图像路径 - Uploading to Google Drive - how to use a base64-encoded image or an image path IE10-base64编码的图像加载错误 - IE10 - base64-encoded image load error 对 base64 URI 支持的更好测试(我可以在 JS 中创建一个大的 base64 编码图像吗?) - A better test for base64 URI support (can I create a large base64-encoded image in JS?) 使用angularjs将SVG中的xlink:href设置为base64编码的图像 - Set xlink:href in svg with angularjs to base64-encoded image 如何在节点js中解码base64编码的json object字符串 - How to decode base64-encoded json object string in node js 如何从 javascript 中的本地文件图像创建 base64 编码的字符串 - How to create a base64-encoded string from a local file image in javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM