Если я сделаю это:
Код: Выделить всё
curl --location 'https://backend-endpoint.com/get-file' >> test.zip
Код: Выделить всё
const convertBinaryToBlob = (binary: string, contentType: string): Blob => {
// Convert the binary string to a byte array
const binaryLen = binary.length;
const bytes = new Uint8Array(binaryLen);
for (let i = 0; i < binaryLen; i++) {
bytes[i] = binary.charCodeAt(i);
}
const blob = new Blob([bytes], { type: contentType });
return blob;
};
clientAPI.getFile().then((resp) => {
if (resp.status === 200) {
let blobContent = convertBinaryToBlob(resp.data, 'application/zip');
const href = URL.createObjectURL(blobContent);
const link = document.createElement('a');
link.href = href;
link.setAttribute('download', 'test.zip');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(href);
}
});
Что я делаю не так? < /p>
Подробнее здесь: https://stackoverflow.com/questions/794 ... ded-via-ja