错误的解码base64 utf8图像文件

时间:2018-11-10 18:53:24

标签: c# node.js base64

我正在使用nodejs来获取base64文件,但是我以错误的方式进行操作,我突然从utf8字符集对base64进行了编码。我想恢复存储在数据库中的文件,我测试了很多方法来取回数据,但结果一无所获。

我上传图片的问题已解决:

Converted base64 image does not work, how can I get true base64 image?

在我的数据库中存储的样本图像是这样的(其png图像的实际大小:23275字节):

https://files.fm/u/vt5f5chn

请帮助我使用任何工具或编程语言来恢复文件。

编辑1:

我使用以下代码将数据存储在mongo中:

在我的服务器文件中(纯nodejs):

    // Get the payload,if any
    const decoder = new StringDecoder('utf-8');
    let payload = '';
    req.on('data', (data) => {
        payload += decoder.write(data);
    });
    req.on('end', () => {
        payload += decoder.end();
        req.data = {
            payload
        });
        // ... other codes

在我的将数据存储在mongo中的api中:

const newAttachment = new TicketAttachment({
    name:fileName,
    type:fileType,
    size:req.data.payload.length,
    content:req.data.payload
});

newAttachment.save();

存储在我的mongo中的数据的图像是:

https://files.fm/u/vq9747zv

0 个答案:

没有答案
相关问题