相关疑难解决方法(0)

通过JavaScript将base64字符串转换为字节数组

我想通过JavaScript将“ base64”字符串转换为字节数组。

我收到了类似URL的字符串。

 ("data:image/jpeg;base64,/9j/4QN6RXhpZgAASUkqAAgAAAAIA)
Run Code Online (Sandbox Code Playgroud)

而且我想将字符串转换为字节数组。因为我需要此字节数组来发送Rest API端点。其余的API Content-type = application / octet-stream。

javascript arrays

5
推荐指数
2
解决办法
2万
查看次数

将字节数组转换为 angular6 中的图像

我已经从服务器以字节数组的形式发送了图像文件。现在我必须将其转换为jpeg文件并将其显示在网页中。

代码:

app.get('/getPhoto/:hash',function(req, res){
    console.log(req.params.hash);
    invoke = require('/Users/sanjeev.natarajan/ipfs/file1.js');

    invoke.getfile(req.params.hash).then((str)=>{
        console.log("resu",str)

        res.send({"Result":str});
    })
    .catch((error) => {
        res.send({"Error":"error in fetching the file through the hashcode"});
    })    
});
Run Code Online (Sandbox Code Playgroud)

我正在从后端接收数据;现在我需要将其转换为 angular6 中的图像

typescript ipfs angular

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

arrays ×1

ipfs ×1

javascript ×1

typescript ×1