From d9a4e365ba04585e3b40a1bb7d2ecfbd90e56947 Mon Sep 17 00:00:00 2001 From: bicochan Date: Wed, 14 May 2025 12:29:24 +0900 Subject: [PATCH] =?UTF-8?q?WIP:=20=EB=8F=99=EC=98=81=EC=83=81=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=ED=8C=90=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachment/api/attachment-service.ts | 16 ++++++++++---- .../attachment/model/attachment-interface.ts | 1 + apps/cs/src/shared/config/api.ts | 1 + apps/cs/src/widgets/post/ui/post-form.tsx | 3 ++- apps/cs/src/widgets/post/ui/post-page.tsx | 2 +- .../post/ui/with-preview-file-uploader.tsx | 22 +++++++++++++++++-- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/apps/cs/src/entities/attachment/api/attachment-service.ts b/apps/cs/src/entities/attachment/api/attachment-service.ts index 406cca549..1565d354e 100644 --- a/apps/cs/src/entities/attachment/api/attachment-service.ts +++ b/apps/cs/src/entities/attachment/api/attachment-service.ts @@ -30,6 +30,10 @@ export class AttachmentApiService implements AttachmentService { await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); } + public async deleteAttachmentByAtflId(atflId: string): Promise { + await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); + } + public async deleteAttachmentByAtflCd(atflCd: string): Promise { await client.delete( `${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/atflCd/${atflCd}`, @@ -43,10 +47,6 @@ export class AttachmentApiService implements AttachmentService { return URL.createObjectURL(blob); } - public async deleteAttachmentByAtflId(atflId: string): Promise { - await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); - } - public async getImageUrlByAtflCd(atflCd: string): Promise { if (!atflCd) return ""; const response = await fetch( @@ -56,6 +56,14 @@ export class AttachmentApiService implements AttachmentService { return URL.createObjectURL(blob); } + public async getMovieThumbnailUrl(atflId: string): Promise { + const response = await fetch( + `${ENDPOINT.ATTACH_SERVICE.MOVIE_THUMBNAIL}/${atflId}`, + ); + const blob = await response.blob(); + return URL.createObjectURL(blob); + } + public async downloadAttachmentByAtflCd( atflCd: string, ): Promise { diff --git a/apps/cs/src/entities/attachment/model/attachment-interface.ts b/apps/cs/src/entities/attachment/model/attachment-interface.ts index 00340e9ae..71b42f1c7 100644 --- a/apps/cs/src/entities/attachment/model/attachment-interface.ts +++ b/apps/cs/src/entities/attachment/model/attachment-interface.ts @@ -41,5 +41,6 @@ export interface AttachmentService { deleteAttachmentByAtflCd: (atflCd: string) => Promise; getImageUrl: (atflId: string) => Promise; getImageUrlByAtflCd: (atflCd: string) => Promise; + getMovieThumbnailUrl: (atflId: string) => Promise; downloadAttachmentByAtflCd: (atflCd: string) => Promise; } diff --git a/apps/cs/src/shared/config/api.ts b/apps/cs/src/shared/config/api.ts index 03c933b56..792fc822e 100644 --- a/apps/cs/src/shared/config/api.ts +++ b/apps/cs/src/shared/config/api.ts @@ -7,6 +7,7 @@ export const ENDPOINT = { TUS_UPLOAD: "/attach-service/api/v1/tus/upload", EDITOR_UPLOAD: "/attach-service/api/v1/upload/editor", IMAGES: "/attach-service/api/v1/images", + MOVIE_THUMBNAIL: "/attach-service/api/v1/movie/thumbnail", ATTACHMENTS: "/attach-service/api/v1/atfl/attachments", DOWNLOAD: "/attach-service/api/v1/atflcd/download", }, diff --git a/apps/cs/src/widgets/post/ui/post-form.tsx b/apps/cs/src/widgets/post/ui/post-form.tsx index 928aef922..cf3c14aab 100644 --- a/apps/cs/src/widgets/post/ui/post-form.tsx +++ b/apps/cs/src/widgets/post/ui/post-form.tsx @@ -412,7 +412,8 @@ function PostForm({ 첨부파일 - {bbsInfo?.bbsTypeCd === "BBSIMAGE" ? ( + {bbsInfo?.bbsTypeCd === "BBSIMAGE" || + bbsInfo?.bbsTypeCd === "BBSMOVIE" ? (
{isFetched ? ( - bbsType === "BBSIMAGE" ? ( + bbsType === "BBSIMAGE" || bbsType === "BBSMOVIE" ? ( ({ form, @@ -21,6 +22,17 @@ function WithPreviewFileUploader({ const [thumbnailUrl, setThumbnailUrl] = useState(""); const [progress, setProgress] = useState(0); + const fileAccept = (bbsTypeCd: BbsType) => { + switch (bbsTypeCd) { + case "BBSIMAGE": + return ".jpeg,.jpg,.png"; + case "BBSMOVIE": + return ".mp4,.mov,.avi,.wmv,.mkv"; + default: + return ""; + } + }; + const handleTusResponse = async (res: HttpResponse) => { const fileInfo = res.getHeader("X-File-Info"); if ( @@ -33,7 +45,13 @@ function WithPreviewFileUploader({ const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; if (atflCd) form.setValue("atflCd" as FieldPath, atflCd); if (atflId) { - const imageUrl = await AttachmentApi.getImageUrl(atflId); + let imageUrl = ""; + if (bbsInfo?.bbsTypeCd === "BBSIMAGE") { + imageUrl = await AttachmentApi.getImageUrl(atflId); + } + if (bbsInfo?.bbsTypeCd === "BBSMOVIE") { + imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId); + } setThumbnailUrl(imageUrl); } }; @@ -78,7 +96,7 @@ function WithPreviewFileUploader({