From ecb42d335f089b23d6afc44f3991db821be47963 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Mon, 7 Nov 2022 05:42:35 -0800 Subject: [PATCH] Fix sharing of non-jpeg --- src/components/Viewer.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/Viewer.vue b/src/components/Viewer.vue index d6007494..751268dd 100644 --- a/src/components/Viewer.vue +++ b/src/components/Viewer.vue @@ -648,9 +648,24 @@ export default class Viewer extends Mixins(GlobalMixin) { // Get image blob const blob = await (await fetch(img.src)).blob(); + + // Fix basename extension + let basename = photo.basename; + let targetExts = []; + if (photo.mimetype === "image/png") { + targetExts = ["png"]; + } else { + targetExts = ["jpg", "jpeg"]; + } + + // Append extension if not found + if (!targetExts.includes(basename.split(".").pop().toLowerCase())) { + basename += "." + targetExts[0]; + } + const data = { files: [ - new File([blob], photo.basename, { + new File([blob], basename, { type: blob.type, }), ],