
--- pom.xml
+++ pom.xml
... | ... | @@ -204,6 +204,13 @@ |
204 | 204 |
<version>1.4.7</version> |
205 | 205 |
</dependency> |
206 | 206 |
|
207 |
+ <!-- Thumbnail 관련 라이브러리 --> |
|
208 |
+ <dependency> |
|
209 |
+ <groupId>net.coobird</groupId> |
|
210 |
+ <artifactId>thumbnailator</artifactId> |
|
211 |
+ <version>0.4.13</version> |
|
212 |
+ </dependency> |
|
213 |
+ |
|
207 | 214 |
|
208 | 215 |
|
209 | 216 |
|
--- server/main/java/kr/co/takensoft/keris/post/service/impl/PostServiceImpl.java
+++ server/main/java/kr/co/takensoft/keris/post/service/impl/PostServiceImpl.java
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 |
import kr.co.takensoft.keris.commonFile.dao.CommonFileDAO; |
12 | 12 |
import kr.co.takensoft.keris.post.dao.PostDAO; |
13 | 13 |
import kr.co.takensoft.keris.post.service.PostService; |
14 |
+import net.coobird.thumbnailator.Thumbnails; |
|
14 | 15 |
import org.apache.commons.io.FilenameUtils; |
15 | 16 |
import org.springframework.beans.factory.annotation.Autowired; |
16 | 17 |
import org.springframework.stereotype.Service; |
... | ... | @@ -19,10 +20,7 @@ |
19 | 20 |
import java.io.File; |
20 | 21 |
import java.io.IOException; |
21 | 22 |
import java.io.InputStream; |
22 |
-import java.util.ArrayList; |
|
23 |
-import java.util.HashMap; |
|
24 |
-import java.util.List; |
|
25 |
-import java.util.UUID; |
|
23 |
+import java.util.*; |
|
26 | 24 |
|
27 | 25 |
/** |
28 | 26 |
* 게시글 관련 서비스 로직 입니다. |
... | ... | @@ -173,6 +171,24 @@ |
173 | 171 |
fileUpload.setFileStatus(CommonFile.FileStatus.BEFORE_INSERT); |
174 | 172 |
fileUpload.setCheckMessage(new CheckMessage(true, "파일 정보 조회 성공")); |
175 | 173 |
fileUtil.absoluteFileCreate(fileUpload, fileOne); |
174 |
+ |
|
175 |
+ // 썸네일 파일명 |
|
176 |
+ String thumbnailName = "thumbnail_" + saveFileName + '.' + fileExtension; |
|
177 |
+ //홍보뉴스의 경우에만 썸네일생성 |
|
178 |
+ int bbs_id = Integer.parseInt(params.get("bbs_id").toString()); |
|
179 |
+ if (bbs_id == 1) { |
|
180 |
+ //jpg는 지원안함 |
|
181 |
+ List<String> supportedFormats = Arrays.asList("jpeg", "png", "bmp", "gif", "wbmp"); |
|
182 |
+ if(supportedFormats.contains(fileExtension.toLowerCase())) { |
|
183 |
+ try { |
|
184 |
+ Thumbnails.of(absolutePath + "/" + saveFileName + '.' + fileExtension) |
|
185 |
+ .size(350, 230) |
|
186 |
+ .toFile(absolutePath + "/" + thumbnailName); |
|
187 |
+ } catch (IOException e) { |
|
188 |
+ e.printStackTrace(); |
|
189 |
+ } |
|
190 |
+ } |
|
191 |
+ } |
|
176 | 192 |
} catch (Exception e) { |
177 | 193 |
fileUpload.setCheckMessage(new CheckMessage(false, "파일 정보 조회 에러", e.getMessage())); |
178 | 194 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?