Skip to content

Commit

Permalink
Merge pull request #131 from LCOGT/fix/output-jpg-downloads
Browse files Browse the repository at this point in the history
convert blob content type and replace if with try catch
  • Loading branch information
LTDakin authored Dec 4, 2024
2 parents f917200 + b77c472 commit a65c4f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/components/Project/ImageAnalysis/ImageDownloadMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ defineEmits(['analysisAction'])
const alertStore = useAlertsStore()
function downloadLink(link, filename, fileType='file'){
if(!link){
alertStore.setAlert('error', `No ${fileType} available for download`)
return
try{
const a = document.createElement('a')
a.href = link
a.download = filename
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (error) {
alertStore.setAlert('error', `Failed to download ${fileType} file`)
}
// Create a link element and click it to download the file
const a = document.createElement('a')
a.href = link
a.download = filename
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
</script>
Expand Down
2 changes: 2 additions & 0 deletions src/stores/thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const useThumbnailsStore = defineStore('thumbnails', {
if (cachedUrl === undefined || cachedUrl === ''){
return getImageFromBasename(size, archive, url, basename).then((response) => {
if (response){
// Convert to image/jpeg for caching as S3 presigned URLs blobs default to binary/octet-stream
response.headers.set('content-type', 'image/jpeg')
return response.blob()
}
return undefined
Expand Down

0 comments on commit a65c4f9

Please sign in to comment.