blob: 8d2cc962bd0425b6ea2c36520b7863b0d278430d [file] [log] [blame]
import {logError} from '../components/error_logger';
/**
* Downloads an asset with the provided URL.
* @param url Asset path.
* @param begin Start byte.
* @param end End byte.
*/
export async function download(
url: string, begin: number, end: number): Promise<ArrayBuffer> {
const response = await fetch(url, {
headers: {
'Range': `bytes=${begin}-${end}`,
},
});
if (response.status === 404) {
logError(`${url} does not exist.`);
}
return response.arrayBuffer();
}