parent
62af0557d1
commit
df504c4e8b
|
@ -11,11 +11,16 @@ import com.hzya.frame.voucher.ae.push.service.IAePushVoucherLogService;
|
||||||
import com.hzya.frame.web.action.DefaultController;
|
import com.hzya.frame.web.action.DefaultController;
|
||||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -99,5 +104,34 @@ public class PushLogController extends DefaultController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//接收文件并下载到相关目录
|
||||||
|
@RequestMapping(value = "/receiveFile", method = RequestMethod.POST)
|
||||||
|
public ResponseEntity<String> receiveFile(@RequestParam("file") MultipartFile file) {
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
String upload_dir = "D:/yonan/file/" + now+"/";
|
||||||
|
File dir = new File(upload_dir);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body("文件不能为空");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 获取原始文件名
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
Path filePath = Paths.get(upload_dir + fileName);
|
||||||
|
|
||||||
|
// 保存文件到指定路径
|
||||||
|
Files.write(filePath, file.getBytes());
|
||||||
|
|
||||||
|
return ResponseEntity.ok("文件上传成功: " + fileName + ",保存路径: " + filePath.toAbsolutePath());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(500).body("文件上传失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,9 @@ spring:
|
||||||
multipart:
|
multipart:
|
||||||
enabled: true
|
enabled: true
|
||||||
#单个文件的大小
|
#单个文件的大小
|
||||||
max-file-size: 100MB
|
max-file-size: 300MB
|
||||||
#单次请求的文件的总大小
|
#单次请求的文件的总大小
|
||||||
max-request-size: 100MB
|
max-request-size: 300MB
|
||||||
# 默认数据源设置
|
# 默认数据源设置
|
||||||
datasource:
|
datasource:
|
||||||
dynamic:
|
dynamic:
|
||||||
|
|
Loading…
Reference in New Issue