您好我们正在使用javascript开发Windows应用程序,我们想从json服务下载一个文件,它返回一些base-64字符串,我们将其转换为字节数组格式,如下所示,二进制数据图片如下所示请给我一些建议如何将该字节数组数据保存到文件并将其保存在本地机器中。谢谢
WinJS.xhr({
url: url, responseType: "arraybuffer",
data: "{" + params + "}",
})
.done(function complete(result) {
var buffer = result.response;
var dataview = new DataView(buffer);
var ints = new Uint32Array(buffer.byteLength / 4);
for (var i = 0; i < ints.length; i++) {
ints[i] = dataview.getUint32(i * 4);
}
var data = ints;
我们收到像这样的二进制数据
答案 0 :(得分:1)
试试这个:
var folder = Windows.Storage.ApplicationData.current.localFolder;
Debug.writeln(folder.path);
folder.createFileAsync("page.html", Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
return Windows.Storage.FileIO.writeTextAsync(file, r.response);
}).then(function () {
Debug.writeln("page saved");
});