22 lines
585 B
HTML
22 lines
585 B
HTML
|
<button class="download-button" onclick="downloadFile('{{ .Get "src" }}', '{{ .Get "name" }}')">
|
||
|
Download
|
||
|
</button>
|
||
|
|
||
|
<script>
|
||
|
async function downloadFile(url, name) {
|
||
|
try {
|
||
|
const response = await fetch(url);
|
||
|
const blob = await response.blob();
|
||
|
const link = document.createElement('a');
|
||
|
link.href = URL.createObjectURL(blob);
|
||
|
link.download = name;
|
||
|
document.body.appendChild(link);
|
||
|
link.click();
|
||
|
document.body.removeChild(link);
|
||
|
} catch (error) {
|
||
|
console.error('Error downloading the file:', error);
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|