I always get this error in the downloaded zip file C:\Users\me\Downloads\test.zip: Unexpected end of archive
My current code is:
var blob = new Blob([data], {
type: 'octet/stream',
});
var zipUrl = window.URL.createObjectURL(blob);
var fileName = orderNo;
fileName += '.zip';
downloadFile(null, fileName, null, zipUrl, null);
The call response is binary (I think). Binary content here
But the preview is base64. Base64 content . And it is right. I check this using fiddle .
You can refer to the network screenshot here
I put the contents of base64 on this line var sampleBytes = base64ToArrayBuffer('');And the downloaded zip just opens perfectly.
Things I've tried so far.
Adding these headers to the GET call
headers var = {Accept: application / octet stream, responseType: 'blob',}; But I getRequest header field responseType is not allowed by Access-Control-Allow-Headers in preflight response.
ajax.service.js AngularJS.
var blob = new Blob([yourBinaryDataAsAnArrayOrAsAString], {type: "application/octet-stream"});
var fileName = "myFileName.myExtension";
saveAs(blob, fileName);
, , . , .
. preview base64 . ? ( , ), binary to base64, .