增加配置
parent
2c2b4747dc
commit
2b82a0911a
|
|
@ -1,86 +0,0 @@
|
|||
package com.njzscloud.supervisory.oss.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njzscloud.common.core.http.constant.Mime;
|
||||
import com.njzscloud.common.core.tuple.Tuple2;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mvc.util.FileResponseUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// @RestController
|
||||
// @RequestMapping("/oss")
|
||||
public class OSSController {
|
||||
|
||||
@Value("${oss.path}")
|
||||
private String path;
|
||||
|
||||
@GetMapping("/end_mlt_upload")
|
||||
public R<?> endMltUpload(String objectName, String uploadId, int partNum) {
|
||||
// Minio.endMltUpload(objectName, uploadId, partNum);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@GetMapping("/start_mlt_upload")
|
||||
public R<Tuple2<String, List<String>>> startMltUpload(
|
||||
String objectName,
|
||||
String contentType,
|
||||
int partNum) {
|
||||
// Minio.startMltUpload(objectName, contentType, partNum)
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@GetMapping("/obtain_presigned_url")
|
||||
public R<Map<String, String>> obtainPresignedUrl(
|
||||
@RequestParam(value = "bucketName") String bucketName,
|
||||
@RequestParam(value = "filename") String filename) {
|
||||
String objectName = IdUtil.fastSimpleUUID();
|
||||
if (StrUtil.isNotBlank(filename)) {
|
||||
objectName = objectName + "." + FileUtil.extName(filename);
|
||||
}
|
||||
// Map<String, String> data = Minio.obtainPresignedUrl(bucketName, objectName);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@GetMapping("/download/{bucketName}/{objectName}")
|
||||
public void obtainFile(
|
||||
@PathVariable("bucketName") String bucketName,
|
||||
@PathVariable("objectName") String objectName,
|
||||
HttpServletResponse response) throws Exception {
|
||||
// Tuple2<InputStream, String> tuple2 = Minio.obtainFile(bucketName, objectName);
|
||||
File file = new File(path + "/" + bucketName + "/" + objectName);
|
||||
if (!file.exists()) {
|
||||
response.sendError(404);
|
||||
return;
|
||||
}
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
FileResponseUtil.download(response, inputStream, Mime.BINARY, objectName);
|
||||
}
|
||||
|
||||
@PostMapping("/upload")
|
||||
public R<?> upload(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
String filename = file.getOriginalFilename();
|
||||
String objectName = IdUtil.fastSimpleUUID();
|
||||
if (StrUtil.isNotBlank(filename)) {
|
||||
objectName = objectName + "." + FileUtil.extName(filename);
|
||||
}
|
||||
InputStream inputStream = file.getInputStream();
|
||||
IoUtil.copy(inputStream, Files.newOutputStream(Paths.get(path + "/test/" + objectName)));
|
||||
inputStream.close();
|
||||
|
||||
return R.success("download/test/" + objectName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
location: /home/zsy-recycling-supervision/server/temp
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/zsy_recycling_supervision?characterEncoding=UTF-8&allowMultiQueries=true&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: a2c21876a63164e1
|
||||
security:
|
||||
auth-ignores:
|
||||
- /dispose_record/report
|
||||
- /project_clearance_detail/report
|
||||
redis:
|
||||
enable: false
|
||||
pubsub: false
|
||||
host: localhost
|
||||
#password: redis
|
||||
database: 0
|
||||
port: 6379
|
||||
|
||||
mail:
|
||||
# 邮件服务器
|
||||
host: smtp.qq.com
|
||||
# 发送邮件的账户
|
||||
username: lzq@qq.com
|
||||
# 授权码
|
||||
password: lzq
|
||||
oss:
|
||||
minio:
|
||||
endpoint: oss-cn-shanghai.aliyuncs.com
|
||||
access-key: LTAI5t9ppUx8fkEnPwnNwmnx
|
||||
secret-key: uxrwL01P1Nw6M3YRFWoMIluY4swKwC
|
||||
bucket-name: tq-cdn
|
||||
region: cn-shanghai
|
||||
|
||||
|
||||
app:
|
||||
district:
|
||||
province: 320000
|
||||
city: 320100
|
||||
|
||||
mybatis-plus:
|
||||
tunnel:
|
||||
enable: false
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
server:
|
||||
port: ${APP_PORT:10086}
|
||||
tomcat:
|
||||
max-http-form-post-size: 20MB
|
||||
port: 10086
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
|
|
|
|||
Loading…
Reference in New Issue