This commit is contained in:
nasir@endelospay.com 2024-06-11 00:23:34 +05:00
parent 9699b230d5
commit e3e44f116e
2 changed files with 15 additions and 5 deletions

View File

@ -37,6 +37,15 @@ const downloadFile = (fileUrl) => {
link.click();
document.body.removeChild(link);
};
const downloadImage = async (imageUrl) => {
try {
const response = await fetch(imageUrl)
const blob = await response.blob()
const fileName = imageUrl.split('/').pop()
saveAs(blob, fileName)
} catch (error) {
console.error('Error downloading image:', error) }
}
</script>
<template>
@ -64,8 +73,9 @@ const downloadFile = (fileUrl) => {
<span class="app-timeline-title" v-if="p_note.note_type=='Notes'">
{{p_note.note}}
</span>
<span class="app-timeline-title" v-if="p_note.note_type=='file'">
<img :src="p_note.note"/>
<span class="app-timeline-title" v-if="p_note.note_type == 'file'">
<img :src="p_note.note" @click="downloadImage(p_note.note)" />
</span>
<span class="app-timeline-meta">{{ formatDateDate(p_note.created_at) }}</span>
<!-- <span></span> -->

View File

@ -77,7 +77,7 @@ const downloadFile = (fileUrl) => {
<span class="app-timeline-title" v-if="p_note.note_type == 'file'">
<img :src="p_note.note" @click="downloadImage(p_note.note)" />
<button @click="downloadImage(p_note.note)">Download Image</button>
</span>