export function fetchBlob(url) {
  return window.fetch(url).then((response) => response.blob());
}

export function downloadBlob(blob, fileName) {
  const url = window.URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.href = url;
  link.setAttribute('download', fileName);
  link.click();
  window.URL.revokeObjectURL(url);
}

export function downloadUrl(url, fileName) {
  return fetchBlob(url).then((blob) => downloadBlob(blob, fileName));
}
