xhttp.open("GET", "https://api.example.com" + file, true);
xhttp.setRequestHeader("content-type", "application/zip");
xhttp.responseType = "blob";
xhttp.onload = function (event) {
var blob = xhttp.response;
//checking file size
var blobSize = xhttp.response.size;
(xhttp.response.size > 0) {
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.dataset.downloadurl = ['text/plain', link.download, link.href].join(':');
link.download = fileName;
link.click();
}
I have deployed it on a server but when I try to access that from the server, the zip files download without any problem. When I try to download from client-server, the file gets corrupted.
The file can be only downloaded with the server's approved IP address. I assume when I try to download the file on the client side, the file doesn't pass through the server IP address.