From 67947d758fa49d160277996e1affec651640d3e0 Mon Sep 17 00:00:00 2001 From: wewewe-ok Date: Wed, 1 May 2024 16:56:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20png,gif=E3=81=A7=E3=82=A2=E3=82=B9?= =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=82=A2=E3=83=BC=E3=83=88=E3=82=92=E3=83=80?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- islands/ImageForm.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/islands/ImageForm.tsx b/islands/ImageForm.tsx index 27ce255..ee66754 100644 --- a/islands/ImageForm.tsx +++ b/islands/ImageForm.tsx @@ -44,7 +44,7 @@ const downloadAsciiArt = (asciiArtFileType: Signal) => { const download = document.createElement("a"); download.href = asciiArt; - download.download = `ascii-art.${asciiArtFileType.value.split("/")[1]}`; + download.download = `ascii-art.${asciiArtFileType.value}`; document.body.appendChild(download); download.click(); document.body.removeChild(download); @@ -74,6 +74,12 @@ export default function ImageForm() { "upload-form", ) as HTMLFormElement; const image = imageElement.files[0]; + const fileType = image.type.split("/")[1]; + // fixme: ここでファイルタイプを取得しているが、サーバー側で取得するように修正する + // APIから取得できるファイルは現状gifのみなので、ここで取得している + asciiArtFileType.value = fileType === "jpeg" || fileType === "jpg" + ? "png" + : fileType; buttonDisable.value = true; isAnnounsing.value = true; @@ -82,7 +88,6 @@ export default function ImageForm() { const blobUrl = await window.URL.createObjectURL(asciiArtBlob); const fileData = new FileReader(); loadImageWhencreateAsciiArt(fileData, blobUrl); - asciiArtFileType.value = asciiArtBlob.type; fileData.readAsDataURL(asciiArtBlob); isActiveFileUpLoderDisable.value = false;