parent
89f624ac7d
commit
dfd4250f47
|
|
@ -33,8 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests() // 페이지 권한 설정
|
||||
.antMatchers("/board/**").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용
|
||||
.antMatchers("/info/**").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용
|
||||
.antMatchers("/file/**", "/board/**", "/info/**").hasRole(Role.USER.name()) // USER, ADMIN 접근 허용
|
||||
.antMatchers("/admin/**").hasRole(Role.ADMIN.name()) // ADMIN만 접근 허용
|
||||
.antMatchers("/user/login").permitAll() // 로그인 페이지는 권한 없이 접근 허용
|
||||
.and() // 로그인 설정
|
||||
|
|
|
|||
|
|
@ -6,24 +6,12 @@ import com.dbnt.kcgfilemanager.service.BoardCategoryService;
|
|||
import com.dbnt.kcgfilemanager.service.BoardService;
|
||||
import com.dbnt.kcgfilemanager.service.CategoryRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.Principal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -135,134 +123,4 @@ public class BoardController {
|
|||
return mav;
|
||||
}
|
||||
|
||||
@GetMapping("/fileDownload")
|
||||
public void fileDownload(Principal principal, Integer contentSeq, Integer fileSeq, HttpServletRequest request, HttpServletResponse response){
|
||||
FileInfo downlodFileInfo = boardService.selectDownloadFileInfo(contentSeq, fileSeq, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
|
||||
|
||||
BufferedInputStream in;
|
||||
BufferedOutputStream out;
|
||||
try {
|
||||
File file = new File(downlodFileInfo.getSavePath(), downlodFileInfo.getConversionName());
|
||||
setDisposition(downlodFileInfo.getFullName(), request, response);
|
||||
in = new BufferedInputStream(new FileInputStream(file));
|
||||
out = new BufferedOutputStream(response.getOutputStream());
|
||||
FileCopyUtils.copy(in, out);
|
||||
out.flush();
|
||||
if(out!=null) out.close();
|
||||
if(in!=null )in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/fileDownloadToZip")
|
||||
public void fileDownloadToZip(Principal principal, Integer contentSeq, @RequestParam(value = "fileSeq") List<Integer> fileSeqList, HttpServletResponse response){
|
||||
List<FileInfo> targetList = boardService.selectDownloadFileInfoList(contentSeq, fileSeqList, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
|
||||
|
||||
BufferedInputStream in;
|
||||
BufferedOutputStream out;
|
||||
|
||||
String tempZipPath = "C:\\kcgFileManager\\tempZip\\";
|
||||
File tempFolder = new File(tempZipPath);
|
||||
if (!tempFolder.exists() || tempFolder.isFile()) {
|
||||
tempFolder.mkdirs();
|
||||
}
|
||||
String downloadFileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
|
||||
|
||||
tempZipPath += downloadFileName+".zip";
|
||||
try{
|
||||
FileOutputStream fout = new FileOutputStream(tempZipPath);
|
||||
ZipOutputStream zout = new ZipOutputStream(fout);
|
||||
for(FileInfo downLoadFile: targetList){
|
||||
ZipEntry zipEntry = new ZipEntry(downLoadFile.getFullName());
|
||||
zout.putNextEntry(zipEntry);
|
||||
|
||||
FileInputStream fin = new FileInputStream(downLoadFile.getSavePath()+"\\"+downLoadFile.getConversionName());
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while((length = fin.read(buffer)) > 0){
|
||||
zout.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
zout.closeEntry();
|
||||
fin.close();
|
||||
}
|
||||
zout.close();
|
||||
|
||||
response.setContentType("application/zip");
|
||||
response.addHeader("Content-Disposition", "attachment; filename="+downloadFileName+".zip");
|
||||
|
||||
FileInputStream fis=new FileInputStream(tempZipPath);
|
||||
ServletOutputStream so=response.getOutputStream();
|
||||
in=new BufferedInputStream(fis);
|
||||
out=new BufferedOutputStream(so);
|
||||
|
||||
byte[] data=new byte[2048];
|
||||
int input;
|
||||
while((input=in.read(data))!=-1){
|
||||
out.write(data,0,input);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
if(out!=null) out.close();
|
||||
if(fis!=null) fis.close();
|
||||
if(in!=null) in.close();
|
||||
if(so!=null) so.close();
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
File tempZip = new File(tempZipPath);
|
||||
tempZip.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String browser = getBrowser(request);
|
||||
|
||||
String dispositionPrefix = "attachment; filename=";
|
||||
String encodedFilename = null;
|
||||
|
||||
if (browser.equals("MSIE")) {
|
||||
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
||||
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
|
||||
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
||||
} else if (browser.equals("Firefox")) {
|
||||
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
||||
} else if (browser.equals("Opera")) {
|
||||
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
||||
} else if (browser.equals("Chrome")) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < filename.length(); i++) {
|
||||
char c = filename.charAt(i);
|
||||
if (c > '~') {
|
||||
sb.append(URLEncoder.encode("" + c, "UTF-8"));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
encodedFilename = sb.toString();
|
||||
} else {
|
||||
throw new IOException("Not supported browser");
|
||||
}
|
||||
|
||||
response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
|
||||
|
||||
if ("Opera".equals(browser)) {
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
private String getBrowser(HttpServletRequest request) {
|
||||
String header = request.getHeader("User-Agent");
|
||||
if (header.indexOf("MSIE") > -1) {
|
||||
return "MSIE";
|
||||
} else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지
|
||||
return "Trident";
|
||||
} else if (header.indexOf("Chrome") > -1) {
|
||||
return "Chrome";
|
||||
} else if (header.indexOf("Opera") > -1) {
|
||||
return "Opera";
|
||||
}
|
||||
return "Firefox";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,169 @@
|
|||
package com.dbnt.kcgfilemanager.controller;
|
||||
|
||||
import com.dbnt.kcgfilemanager.model.FileInfo;
|
||||
import com.dbnt.kcgfilemanager.model.UserInfo;
|
||||
import com.dbnt.kcgfilemanager.service.BoardService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.Principal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/file")
|
||||
public class FileController {
|
||||
|
||||
private final BoardService boardService;
|
||||
|
||||
@Value("${spring.servlet.multipart.location}")
|
||||
private String locationPath;
|
||||
|
||||
@GetMapping("/fileDownload")
|
||||
public void fileDownload(Principal principal, Integer contentSeq, Integer fileSeq, HttpServletRequest request, HttpServletResponse response){
|
||||
FileInfo downloadFile = boardService.selectDownloadFileInfo(contentSeq, fileSeq, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
|
||||
|
||||
BufferedInputStream in;
|
||||
BufferedOutputStream out;
|
||||
try {
|
||||
File file = new File(downloadFile.getSavePath(), downloadFile.getConversionName());
|
||||
|
||||
setDisposition(downloadFile.getFullName(), request, response);
|
||||
in = new BufferedInputStream(new FileInputStream(file));
|
||||
out = new BufferedOutputStream(response.getOutputStream());
|
||||
FileCopyUtils.copy(in, out);
|
||||
out.flush();
|
||||
if(out!=null) out.close();
|
||||
if(in!=null )in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/fileDownloadToZip")
|
||||
public void fileDownloadToZip(Principal principal, Integer contentSeq, @RequestParam(value = "fileSeq") List<Integer> fileSeqList, HttpServletResponse response){
|
||||
List<FileInfo> targetList = boardService.selectDownloadFileInfoList(contentSeq, fileSeqList, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
|
||||
|
||||
BufferedInputStream in;
|
||||
BufferedOutputStream out;
|
||||
|
||||
String tempZipPath = locationPath+File.separator+"tempZip"+File.separator;
|
||||
File tempFolder = new File(tempZipPath);
|
||||
if (!tempFolder.exists() || tempFolder.isFile()) {
|
||||
tempFolder.mkdirs();
|
||||
}
|
||||
String downloadFileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
|
||||
|
||||
tempZipPath += downloadFileName+".zip";
|
||||
|
||||
try{
|
||||
FileOutputStream fout = new FileOutputStream(tempZipPath);
|
||||
ZipOutputStream zout = new ZipOutputStream(fout);
|
||||
for(FileInfo downLoadFile: targetList){
|
||||
ZipEntry zipEntry = new ZipEntry(downLoadFile.getFullName());
|
||||
zout.putNextEntry(zipEntry);
|
||||
File savedFile = new File(downLoadFile.getSavePath(), downLoadFile.getConversionName());
|
||||
FileInputStream fin = new FileInputStream(savedFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while((length = fin.read(buffer)) > 0){
|
||||
zout.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
zout.closeEntry();
|
||||
fin.close();
|
||||
}
|
||||
zout.close();
|
||||
|
||||
response.setContentType("application/zip");
|
||||
response.addHeader("Content-Disposition", "attachment; filename="+downloadFileName+".zip");
|
||||
|
||||
FileInputStream fis=new FileInputStream(tempZipPath);
|
||||
ServletOutputStream so=response.getOutputStream();
|
||||
in=new BufferedInputStream(fis);
|
||||
out=new BufferedOutputStream(so);
|
||||
|
||||
byte[] data=new byte[2048];
|
||||
int input;
|
||||
while((input=in.read(data))!=-1){
|
||||
out.write(data,0,input);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
if(out!=null) out.close();
|
||||
if(fis!=null) fis.close();
|
||||
if(in!=null) in.close();
|
||||
if(so!=null) so.close();
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
File tempZip = new File(tempZipPath);
|
||||
tempZip.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String browser = getBrowser(request);
|
||||
|
||||
String dispositionPrefix = "attachment; filename=";
|
||||
String encodedFilename = null;
|
||||
|
||||
if (browser.equals("MSIE")) {
|
||||
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
||||
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
|
||||
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
||||
} else if (browser.equals("Firefox")) {
|
||||
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
||||
} else if (browser.equals("Opera")) {
|
||||
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
||||
} else if (browser.equals("Chrome")) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < filename.length(); i++) {
|
||||
char c = filename.charAt(i);
|
||||
if (c > '~') {
|
||||
sb.append(URLEncoder.encode("" + c, "UTF-8"));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
encodedFilename = sb.toString();
|
||||
} else {
|
||||
throw new IOException("Not supported browser");
|
||||
}
|
||||
|
||||
response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
|
||||
|
||||
if ("Opera".equals(browser)) {
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
private String getBrowser(HttpServletRequest request) {
|
||||
String header = request.getHeader("User-Agent");
|
||||
if (header.indexOf("MSIE") > -1) {
|
||||
return "MSIE";
|
||||
} else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지
|
||||
return "Trident";
|
||||
} else if (header.indexOf("Chrome") > -1) {
|
||||
return "Chrome";
|
||||
} else if (header.indexOf("Opera") > -1) {
|
||||
return "Opera";
|
||||
}
|
||||
return "Firefox";
|
||||
}
|
||||
}
|
||||
|
|
@ -7,8 +7,6 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
|
@ -94,9 +95,9 @@ public class BoardCategoryService {
|
|||
public String makeFilePath(Integer categorySeq){
|
||||
BoardCategory category = boardCategoryRepository.findById(categorySeq).orElse(null);
|
||||
if(category.getParentSeq()==null){
|
||||
return "C:\\kcgFileManager\\"+category.getCategoryName();
|
||||
return File.separator+category.getCategoryName();
|
||||
}
|
||||
return makeFilePath(category.getParentSeq())+"\\"+category.getCategoryName();
|
||||
return makeFilePath(category.getParentSeq())+File.separator+category.getCategoryName();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
@ -104,7 +105,6 @@ public class BoardCategoryService {
|
|||
for(BoardCategory category: categoryList){
|
||||
switch (category.getStatus()){
|
||||
case "deleted":
|
||||
/*게시물 삭제 로직 필요.*/
|
||||
deleteContentToCategorySeq(category.getCategorySeq());
|
||||
boardCategoryRepository.delete(category);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.dbnt.kcgfilemanager.mapper.BoardMapper;
|
|||
import com.dbnt.kcgfilemanager.model.*;
|
||||
import com.dbnt.kcgfilemanager.repository.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -30,6 +31,8 @@ public class BoardService {
|
|||
private final HashTagLinkRepository hashTagLinkRepository;
|
||||
private final UserInfoRepository userInfoRepository;
|
||||
|
||||
@Value("${spring.servlet.multipart.location}")
|
||||
private String locationPath;
|
||||
|
||||
public List<SearchResult> fullSearchBoardContent(List<Integer> categorySeqList, Board board) {
|
||||
board.setRowCnt(Integer.MAX_VALUE);
|
||||
|
|
@ -119,9 +122,9 @@ public class BoardService {
|
|||
int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1);
|
||||
for(MultipartFile file : content.getFileList()){
|
||||
String saveName = UUID.randomUUID().toString();
|
||||
String path = boardCategoryService.makeFilePath(content.getCategorySeq());
|
||||
String path = locationPath+boardCategoryService.makeFilePath(content.getCategorySeq());
|
||||
|
||||
File saveFile = new File(path+"\\"+saveName);
|
||||
File saveFile = new File(path+File.separator+saveName);
|
||||
if(file.getSize()!=0){ // 저장될 파일 확인
|
||||
if(!saveFile.exists()){ // 저장될 경로 확인
|
||||
if(saveFile.getParentFile().mkdirs()){
|
||||
|
|
@ -139,12 +142,13 @@ public class BoardService {
|
|||
}
|
||||
}
|
||||
|
||||
String[] originalFilename = Objects.requireNonNull(file.getOriginalFilename()).split("\\.");
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
int extentionIdx = originalFilename.lastIndexOf(".");
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setContentSeq(content.getContentSeq());
|
||||
fileInfo.setFileSeq(fileSeq++);
|
||||
fileInfo.setOriginalName(originalFilename[0]);
|
||||
fileInfo.setExtention(originalFilename[1]);
|
||||
fileInfo.setOriginalName(originalFilename.substring(0, extentionIdx));
|
||||
fileInfo.setExtention(originalFilename.substring(extentionIdx+1));
|
||||
fileInfo.setConversionName(saveName);
|
||||
fileInfo.setFileSize(calculationSize(file.getSize()));
|
||||
fileInfo.setSavePath(path);
|
||||
|
|
@ -260,7 +264,7 @@ public class BoardService {
|
|||
List<FileInfo> fileInfoList = fileInfoRepository.findByContentSeqOrderByFileSeqAsc(contentSeq);
|
||||
for(FileInfo fileInfo: fileInfoList){
|
||||
if(fileSeqList.contains(fileInfo.getFileSeq())){
|
||||
fileInfoService.deleteStoredFile(fileInfo.getSavePath(), fileInfo.getConversionName());
|
||||
fileInfoService.deleteStoredFile(new File(fileInfo.getSavePath(), fileInfo.getConversionName()));
|
||||
saveBoardLog(contentSeq, LogStatus.FILE_REMOVE, fileInfo.getFullName(), userId);
|
||||
fileInfoRepository.delete(fileInfo);
|
||||
}
|
||||
|
|
@ -282,8 +286,23 @@ public class BoardService {
|
|||
}
|
||||
|
||||
public List<HashMap<String, Object>> getDiskInfoList() {
|
||||
/*저장공간 확인*/
|
||||
File[] drives = File.listRoots();
|
||||
/*설정된 경로의 용량 확인*/
|
||||
List<HashMap<String, Object>> diskInfoList = new ArrayList<>();
|
||||
File storage = new File(locationPath);
|
||||
double totalSize = storage.getTotalSpace();
|
||||
double useSize = storage.getUsableSpace();
|
||||
double freeSize = totalSize - useSize;
|
||||
|
||||
HashMap<String, Object> diskInfo = new HashMap<>();
|
||||
diskInfo.put("driveName", storage.getAbsolutePath());
|
||||
diskInfo.put("totalSize", calculationSize(totalSize));
|
||||
diskInfo.put("useSize", calculationSize(useSize));
|
||||
diskInfo.put("freeSize", calculationSize(freeSize));
|
||||
diskInfo.put("useSizePer", Math.round(useSize/totalSize*10000)/100d);
|
||||
diskInfoList.add(diskInfo);
|
||||
return diskInfoList;
|
||||
/*전체 저장공간 확인*/
|
||||
/*File[] drives = File.listRoots();
|
||||
List<HashMap<String, Object>> diskInfoList = new ArrayList<>();
|
||||
for(File drive : drives) {
|
||||
double totalSize = drive.getTotalSpace();
|
||||
|
|
@ -298,6 +317,6 @@ public class BoardService {
|
|||
diskInfo.put("useSizePer", Math.round(useSize/totalSize*10000)/100d);
|
||||
diskInfoList.add(diskInfo);
|
||||
}
|
||||
return diskInfoList;
|
||||
return diskInfoList;*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.dbnt.kcgfilemanager.config.LogStatus;
|
|||
import com.dbnt.kcgfilemanager.model.FileInfo;
|
||||
import com.dbnt.kcgfilemanager.repository.FileInfoRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -17,13 +18,12 @@ public class FileInfoService {
|
|||
public void deleteFileInfoAll(int contentSeq){
|
||||
List<FileInfo> fileInfoList = fileInfoRepository.findByContentSeqOrderByFileSeqAsc(contentSeq);
|
||||
for(FileInfo fileInfo: fileInfoList){
|
||||
deleteStoredFile(fileInfo.getSavePath(), fileInfo.getConversionName());
|
||||
deleteStoredFile(new File(fileInfo.getSavePath(), fileInfo.getConversionName()));
|
||||
}
|
||||
fileInfoRepository.deleteAll(fileInfoList);
|
||||
}
|
||||
|
||||
public void deleteStoredFile(String savePath, String conversionName){
|
||||
File deleteFile = new File(savePath, conversionName);
|
||||
public void deleteStoredFile(File deleteFile){
|
||||
deleteFile.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
spring.devtools.livereload.enabled=true
|
||||
|
||||
#file upload size
|
||||
#file upload
|
||||
spring.servlet.multipart.location=C:\\kcgFileManager
|
||||
spring.servlet.multipart.max-file-size=200MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#file upload size
|
||||
#file upload
|
||||
spring.servlet.multipart.location=C:\\kcgFileManager
|
||||
spring.servlet.multipart.max-file-size=200MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#file upload size
|
||||
#file upload
|
||||
spring.servlet.multipart.location=/data/kcgFM/files
|
||||
spring.servlet.multipart.max-file-size=200MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ $(document).on('click', '#logTab', function (){
|
|||
})
|
||||
|
||||
$(document).on('click', '.fileDownLink', function (){
|
||||
let url = "/board/fileDownload?"
|
||||
let url = "/file/fileDownload?"
|
||||
url += "contentSeq="+Number($("#detailViewContentSeq").val());
|
||||
url += "&fileSeq="+$(this).attr("data-fileseq");
|
||||
window.open(encodeURI(url));
|
||||
|
|
@ -53,7 +53,7 @@ $(document).on('click', '.fileDownLink', function (){
|
|||
$(document).on('click', '#zipDownBtn', function (){
|
||||
const checkFiles = $(".fileCheckBox:checked");
|
||||
if(checkFiles.length>0){
|
||||
let url = "/board/fileDownloadToZip?"
|
||||
let url = "/file/fileDownloadToZip?"
|
||||
url += "contentSeq="+Number($("#detailViewContentSeq").val());
|
||||
checkFiles.each(function (idx, el){
|
||||
url += "&fileSeq="+Number($(el).attr("data-fileseq"))
|
||||
|
|
|
|||
Loading…
Reference in New Issue