Skip to content

Commit

Permalink
[Fix] #56 이미지 업로드 기능 수정
Browse files Browse the repository at this point in the history
이미지 업로드 기능 수정
  • Loading branch information
hyeiis authored Dec 4, 2023
2 parents ebb1a6c + b3f51bf commit ec93b0f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/detail/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function urlToFile(url: any, filename: any) {
throw new Error(errorObj.error);
}
const blob = await res.blob();
// const extension = filename.split(".").pop();
const extension = filename.split(".").pop();

let mimeType = "";
Expand Down Expand Up @@ -146,7 +147,9 @@ export default function EditDetail(): JSX.Element {
await Promise.all(
initialImages.map((image) => {
const filename = image.imageUrl.split("/").pop() || "image";
return urlToFile(image.imageUrl, filename);
const filenameWithoutPath =
filename.split("_weatherfit_").pop() || filename; // 이미지 파일명 추출
return urlToFile(image.imageUrl, filenameWithoutPath);
}),
)
).filter(Boolean);
Expand All @@ -168,6 +171,8 @@ export default function EditDetail(): JSX.Element {
deletedImages: deleteImageIds,
};

// imageUrl 보낼 때 앞에 https://~~ 다 지우고 test1.jpeg만 보내는 형식으로

formData.append("board", JSON.stringify(boardData));
allImages.forEach((image) => {
formData.append("images", image);
Expand Down

0 comments on commit ec93b0f

Please sign in to comment.