|
@ -2,6 +2,7 @@ package com.iflytop.nuclear.controller; |
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Controller; |
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
@ -21,9 +22,9 @@ import java.util.Set; |
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/upload") |
|
|
|
|
|
|
|
|
@CrossOrigin |
|
|
public class UploadController { |
|
|
public class UploadController { |
|
|
@PostMapping("/xls") |
|
|
|
|
|
|
|
|
@PostMapping("/upload") |
|
|
public String uploadToLocal(MultipartFile file){ |
|
|
public String uploadToLocal(MultipartFile file){ |
|
|
// 获取文件原本的名字 |
|
|
// 获取文件原本的名字 |
|
|
String originName = file.getOriginalFilename(); |
|
|
String originName = file.getOriginalFilename(); |
|
@ -48,7 +49,7 @@ public class UploadController { |
|
|
//日期格式 |
|
|
//日期格式 |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
|
|
String format = sdf.format(new Date()); |
|
|
String format = sdf.format(new Date()); |
|
|
String savePath = System.getProperty("user.dir") + "\\" + "nuclear" + "\\" + "files" + "\\" + fileType + "\\" + format; |
|
|
|
|
|
|
|
|
String savePath = System.getProperty("user.dir") + "/" + "uploadfiles" + "/" + fileType + "/" + format; |
|
|
// 保存文件的文件夹 |
|
|
// 保存文件的文件夹 |
|
|
File folder = new File(savePath); |
|
|
File folder = new File(savePath); |
|
|
// 判断路径是否存在,不存在则自动创建 |
|
|
// 判断路径是否存在,不存在则自动创建 |
|
|