I have a web application. Which is used to send files And there is a functionality that download all files in the ZIP formate.
The Problem is when i download any zip file my web browser use GPU.
is it conserning or it is normal thing.
const xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.responseType = 'blob';
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(dataBody));
xhr.onprogress = function (e) {
// console.log("load", e);
if (e.lengthComputable) {
const progress = (e.loaded / e.total) * 100;
setProgress(Math.ceil(progress));
}
};
xhr.onload = function (e) {
if (this.status === 200) {
const blob = new Blob([this.response], { type: 'application/zip' });
const urls = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = urls;
link.setAttribute('download', `FileShare-${Date.now()}.zip`);
document.body.appendChild(link);
link.click();
link.remove();
}
};
// xhr on error
xhr.onerror = function (e) {
console.log("error in xhr", e);
setIsDownloadProgress(false);
setProgress(0);
};
xhr.onloadend = function (e) {
setIsDownloadProgress(false);
setProgress(0);
setToastMessage((prev) => {
return {
...prev,
show: false,
}
});
}