I am downloading the file from server using WInJS.xhr. and the content-type is application/pdf. Response is also getting properly from server. file is created but when I am opening the file it is showing me the error that "content may be damaged
or not properly decoded". What is missing here. Here is my code.
WinJS.xhr({ url: url,responseType:'arraybuffer', user: 'user', password: 'pass' })
.done(
function (request) {
var arrayResponse = request.response;
var buf = new ArrayBuffer(arrayResponse.length);
var ints = new Uint8Array(buf);
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync("newfile.pdf", Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (newFile) {
Windows.Storage.FileIO.writeBytesAsync(newFile, ints);
}, function onerror() {
console.log("Error in saving the file");
});
});