我有一个名为file_test的字节数组,我只想下载字节数据。
当我下载它。它看起来像这样。
http://i.stack.imgur.com/Gxm83.png
我该如何解决?
function download(strData, strFileName, strMimeType) {
var D = document,
A = arguments,
a = D.createElement("a"),
d = A[0],
n = A[1],
t = A[2];
//build download link:
a.href = "data:" + strMimeType + "," + strData;
if ('download' in a) {
a.setAttribute("download", n);
a.innerHTML = "downloading...";
D.body.appendChild(a);
setTimeout(function() {
var e = D.createEvent("MouseEvents");
e.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
D.body.removeChild(a);
}, 66);
return true;
};
}
file_test// file_test = [255],[216],[255],[224],[0],[16],[74],[70],[73], more
download(file_test, 'filename.jpg', 'image/jpeg');