Fix sharing of non-jpeg

pull/175/head
Varun Patil 2022-11-07 05:42:35 -08:00
parent a489b504a4
commit ecb42d335f
1 changed files with 16 additions and 1 deletions

View File

@ -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,
}),
],