@@ -140,20 +140,33 @@ public void updateProductDetail(DetailUpdateRequestDTO dto, MultipartFile[] file
140140 try {
141141 // 입력 받은 제목을 NFKC 정규화 적용 (전각/반각, 분해형/조합형 등 모든 호환성 문자를 통일)
142142 String normalizedTitle = Normalizer .normalize (dto .getTitle (), Normalizer .Form .NFKC );
143+
144+ if (!isValidTitle (normalizedTitle ))
145+ throw new RuntimeException ("제목 유효성 검사 실패" );
146+
147+ if (!isValidPlot (dto .getPlot ()))
148+ throw new RuntimeException ("줄거리 유효성 검사 실패" );
149+
150+ if (dto .getAny () < 0 || dto .getMale () < 0 || dto .getFemale () < 0 )
151+ throw new RuntimeException ("등장인물이 0명 이상이어야 함" );
152+
153+ if (dto .getStageComment () == null )
154+ throw new RuntimeException ("무대 설명이 작성되어야 함" );
155+
156+ if (dto .getRunningTime () <= 0 )
157+ throw new RuntimeException ("공연 시간이 0분 이상이어야 함" );
158+
159+ if (dto .getScene () < 0 || dto .getAct () < 0 )
160+ throw new RuntimeException ("장과 막이 작성되어야 함" );
161+
143162 final ProductEntity product = productRepo .findById (dto .getId ());
144163
145164 if (product == null )
146165 throw new RuntimeException ("상품을 찾을 수 업습니다." );
147166
148- if (!isValidTitle (normalizedTitle ))
149- throw new RuntimeException ("제목 유효성 검사 실패" );
150-
151167 if (product .getChecked () == ProductStatus .WAIT )
152168 throw new RuntimeException ("등록 심사 중인 작품" );
153169
154- if (!isValidPlot (dto .getPlot ()))
155- throw new RuntimeException ("줄거리 유효성 검사 실패" );
156-
157170 String scriptImageFilePath = null ;
158171 if (file1 != null && file1 .length > 0 && !file1 [0 ].isEmpty ())
159172 scriptImageFilePath = uploadScriptImage (file1 , dto .getTitle (), dto .getId ());
@@ -189,18 +202,7 @@ else if (dto.getDescriptionPath() != null)
189202 product .setDescriptionPath (descriptionFilePath );
190203 product .setPlot (dto .getPlot ());
191204
192- if (dto .getAny () < 0 || dto .getMale () < 0 || dto .getFemale () < 0 )
193- throw new RuntimeException ("등장인물이 0명 이상이어야 함" );
194-
195- if (dto .getStageComment () == null )
196- throw new RuntimeException ("무대 설명이 작성되어야 함" );
197-
198- if (dto .getRunningTime () <= 0 )
199- throw new RuntimeException ("공연 시간이 0분 이상이어야 함" );
200-
201- if (dto .getScene () < 0 || dto .getAct () < 0 )
202- throw new RuntimeException ("장과 막이 작성되어야 함" );
203-
205+ // 개요
204206 product .setAny (dto .getAny ());
205207 product .setMale (dto .getMale ());
206208 product .setFemale (dto .getFemale ());
@@ -244,9 +246,16 @@ public void deleteProduct(final UUID productId, final UUID userId) {
244246 private String extractS3KeyFromURL (final String S3URL ) {
245247 try {
246248 String decodedUrl = URLDecoder .decode (S3URL , StandardCharsets .UTF_8 );
247- final URL url = (new URI (decodedUrl )).toURL ();
248249
249- return url .getPath ().startsWith ("/" ) ? url .getPath ().substring (1 ) : url .getPath ();
250+ // 도메인 부분 제거
251+ if (decodedUrl .startsWith (bucketURL )) {
252+ String key = decodedUrl .substring (bucketURL .length ());
253+ key = key .replace ("\\ " , "/" );
254+
255+ return key ;
256+ }
257+
258+ throw new RuntimeException ("올바르지 않은 S3 URL 형식: " + decodedUrl );
250259 } catch (Exception e ) {
251260 throw new RuntimeException ("S3 URL에서 키 추출 실패" , e );
252261 }
@@ -289,7 +298,7 @@ protected String uploadScriptImage(final MultipartFile[] files, final String tit
289298 final String [] fileName = new String []{Objects .requireNonNull (name ).substring (0 , name .length () - 4 )};
290299
291300 // S3 Key 구성
292- final String S3Key = scriptImageBucketFolder + fileName [0 ] + "\\ " + title + "\\ " + dateFormat .format (time ) + ".jpg" ;
301+ final String S3Key = scriptImageBucketFolder + fileName [0 ] + "/ " + title + "/ " + dateFormat .format (time ) + ".jpg" ;
293302
294303 final ObjectMetadata metadata = new ObjectMetadata ();
295304 metadata .setContentLength (files [0 ].getSize ());
@@ -337,7 +346,7 @@ protected String uploadDescription(final MultipartFile[] files, final String tit
337346 final String [] fileName = new String []{Objects .requireNonNull (name ).substring (0 , name .length () - 4 )};
338347
339348 // S3 Key 구성
340- final String S3Key = descriptionBucketFolder + fileName [0 ] + "\\ " + title + "\\ " + dateFormat .format (time ) + ".pdf" ;
349+ final String S3Key = descriptionBucketFolder + fileName [0 ] + "/ " + title + "/ " + dateFormat .format (time ) + ".pdf" ;
341350
342351 final ObjectMetadata metadata = new ObjectMetadata ();
343352 metadata .setContentLength (files [0 ].getSize ());
0 commit comments