feat: 又拍云存储功能
This commit is contained in:
@@ -1,18 +1,25 @@
|
|||||||
package com.schisandra.oss.application.controller;
|
package com.schisandra.oss.application.controller;
|
||||||
|
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.core.up.UpOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.up.UpOssConfiguration;
|
||||||
|
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 又拍云对象存储配置表 controller
|
* 又拍云对象存储配置表 controller
|
||||||
@@ -28,36 +35,111 @@ public class SchisandraOssUpController {
|
|||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssUpDomainService schisandraOssUpDomainService;
|
private SchisandraOssUpDomainService schisandraOssUpDomainService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UpOssConfiguration upOssConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增又拍云对象存储配置表
|
* @description: 初始化
|
||||||
|
* @param: []
|
||||||
|
* @return: void
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 上午11:36
|
||||||
*/
|
*/
|
||||||
@RequestMapping("add")
|
@PostMapping("init")
|
||||||
|
public void init(@RequestParam("userId") String userId) {
|
||||||
|
try {
|
||||||
|
upOssConfiguration.upOssClient(userId);
|
||||||
|
log.info("用户:{} 又拍云oss初始化成功", userId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("用户:{} 又拍云oss初始化失败", userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 获取指定文件信息
|
||||||
|
* @param: [userId,fileName]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 上午11:42
|
||||||
|
*/
|
||||||
|
@PostMapping("getInfo")
|
||||||
|
public Result getInfo(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
||||||
|
UpOssClient bean = SpringUtil.getBean(userId);
|
||||||
|
OssInfo info = bean.getInfo(fileName);
|
||||||
|
return Result.ok(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 单个文件上传
|
||||||
|
* @param: [userId, fileName, file, isOverride]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:00
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@PostMapping("upload")
|
||||||
|
public Result upload(@RequestParam("userId") String userId, @RequestParam("file") MultipartFile file, @RequestParam("isOverride") Boolean isOverride) {
|
||||||
|
UpOssClient bean = SpringUtil.getBean(userId);
|
||||||
|
String originalFileName = file.getOriginalFilename();
|
||||||
|
InputStream is = file.getInputStream();
|
||||||
|
OssInfo ossInfo = bean.upLoad(is, originalFileName, isOverride);
|
||||||
|
return Result.ok(ossInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 删除文件
|
||||||
|
* @param: [userId, fileName]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:21
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteFile")
|
||||||
|
public Result deleteFile(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
||||||
|
UpOssClient bean = SpringUtil.getBean(userId);
|
||||||
|
bean.delete(fileName);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 下载文件
|
||||||
|
* @param: [userId, fileName, response]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:55
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("download")
|
||||||
|
public Result download(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName, HttpServletResponse response) {
|
||||||
|
UpOssClient bean = SpringUtil.getBean(userId);
|
||||||
|
ServletOutputStream output = response.getOutputStream();
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
bean.downLoad(output, fileName);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 新增又拍云对象存储配置
|
||||||
|
* @param: [schisandraOssUpDTO]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Boolean>
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:14
|
||||||
|
*/
|
||||||
|
@PostMapping("add")
|
||||||
public Result<Boolean> add(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
public Result<Boolean> add(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssUpController.add.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
log.info("SchisandraOssUpController.add.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getId(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getUserId(), "UserId不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserId(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getBasePath(), "BasePath不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBasePath(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getBucketName(), "BucketName不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBucketName(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getUserName(), "UserName不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserName(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getPassword(), "Password不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPassword(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTimeout(), "默认的超时时间:30秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getApiDomain(), "默认为自动识别接入点不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssUpBO SchisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
SchisandraOssUpBO SchisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
||||||
return Result.ok(schisandraOssUpDomainService.add(SchisandraOssUpBO));
|
return Result.ok(schisandraOssUpDomainService.add(SchisandraOssUpBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -68,35 +150,19 @@ public class SchisandraOssUpController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改又拍云对象存储配置表
|
* @description: 修改又拍云对象存储配置
|
||||||
|
* @param: [schisandraOssUpDTO]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Boolean>
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:14
|
||||||
*/
|
*/
|
||||||
@RequestMapping("update")
|
@PostMapping("update")
|
||||||
public Result<Boolean> update(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
public Result<Boolean> update(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssUpController.update.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
log.info("SchisandraOssUpController.update.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPassword(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTimeout(), "默认的超时时间:30秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getApiDomain(), "默认为自动识别接入点不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssUpBO schisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
SchisandraOssUpBO schisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
||||||
return Result.ok(schisandraOssUpDomainService.update(schisandraOssUpBO));
|
return Result.ok(schisandraOssUpDomainService.update(schisandraOssUpBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -106,36 +172,22 @@ public class SchisandraOssUpController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除又拍云对象存储配置表
|
* @description: 删除又拍云对象存储配置
|
||||||
|
* @param: [schisandraOssUpDTO]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Boolean>
|
||||||
|
* @author: landaiqing
|
||||||
|
* @date: 2024/6/28 下午3:14
|
||||||
*/
|
*/
|
||||||
@RequestMapping("delete")
|
@DeleteMapping("delete")
|
||||||
public Result<Boolean> delete(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
public Result<Boolean> delete(@RequestBody SchisandraOssUpDTO schisandraOssUpDTO) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssUpController.delete.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
log.info("SchisandraOssUpController.delete.dto:{}", JSON.toJSONString(schisandraOssUpDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getId(), "不能为空");
|
Preconditions.checkNotNull(schisandraOssUpDTO.getId(), "Id不能为空");
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUserName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPassword(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTimeout(), "默认的超时时间:30秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getApiDomain(), "默认为自动识别接入点不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssUpDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssUpBO schisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
SchisandraOssUpBO schisandraOssUpBO = SchisandraOssUpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssUpDTO);
|
||||||
return Result.ok(schisandraOssUpDomainService.delete(schisandraOssUpBO));
|
return Result.ok(schisandraOssUpDomainService.delete(schisandraOssUpBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -44,6 +44,8 @@ public class SchisandraOssTencentDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地域
|
* 地域
|
||||||
*/
|
*/
|
||||||
|
@@ -22,6 +22,7 @@ import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@@ -20,36 +20,35 @@ import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
|||||||
import com.upyun.ParallelUploader;
|
import com.upyun.ParallelUploader;
|
||||||
import com.upyun.RestManager;
|
import com.upyun.RestManager;
|
||||||
import com.upyun.UpException;
|
import com.upyun.UpException;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author zlg
|
||||||
* @description:
|
* @description:
|
||||||
* @param:
|
* @param:
|
||||||
* @return:
|
* @return:
|
||||||
* @author zlg
|
|
||||||
* @date: 2024/6/25 14:40
|
* @date: 2024/6/25 14:40
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@Component
|
||||||
public class UpOssClient implements StandardOssClient {
|
public class UpOssClient implements StandardOssClient {
|
||||||
|
|
||||||
public static final String REST_OBJECT_NAME = "restManager";
|
public static final String REST_OBJECT_NAME = "restManager";
|
||||||
public static final String PARALLEL_OBJECT_NAME = "parallelUploader";
|
public static final String PARALLEL_OBJECT_NAME = "parallelUploader";
|
||||||
|
|
||||||
private RestManager restManager;
|
private RestManager restManager;
|
||||||
private ParallelUploader parallelUploader;
|
private ParallelUploader parallelUploader;
|
||||||
private UpOssConfig upOssConfig;
|
private UpOssConfig upOssConfig;
|
||||||
@@ -206,8 +205,8 @@ public class UpOssClient implements StandardOssClient {
|
|||||||
Response fileInfo = restManager.getFileInfo(key);
|
Response fileInfo = restManager.getFileInfo(key);
|
||||||
Headers headers = fileInfo.headers();
|
Headers headers = fileInfo.headers();
|
||||||
ossInfo.setLength(headers.get(RestManager.PARAMS.X_UPYUN_FILE_SIZE.getValue()));
|
ossInfo.setLength(headers.get(RestManager.PARAMS.X_UPYUN_FILE_SIZE.getValue()));
|
||||||
ossInfo.setCreateTime(DateUtil.date(headers.getDate(RestManager.PARAMS.X_UPYUN_FILE_DATE.getValue())).toString(DatePattern.NORM_DATETIME_PATTERN));
|
ossInfo.setCreateTime(DateUtil.date(Long.parseLong(Objects.requireNonNull(headers.get(RestManager.PARAMS.X_UPYUN_FILE_DATE.getValue())))).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||||
ossInfo.setLastUpdateTime(DateUtil.date(headers.getDate(RestManager.PARAMS.X_UPYUN_FILE_DATE.getValue())).toString(DatePattern.NORM_DATETIME_PATTERN));
|
ossInfo.setLastUpdateTime(DateUtil.date(Long.parseLong(Objects.requireNonNull(headers.get(RestManager.PARAMS.X_UPYUN_FILE_DATE.getValue())))).toString(DatePattern.NORM_DATETIME_PATTERN));
|
||||||
} else {
|
} else {
|
||||||
ossInfo = getDirectoryOssInfo(key);
|
ossInfo = getDirectoryOssInfo(key);
|
||||||
}
|
}
|
||||||
|
@@ -52,26 +52,32 @@ public class UpOssConfiguration {
|
|||||||
public StandardOssClient upOssClient(String userId) {
|
public StandardOssClient upOssClient(String userId) {
|
||||||
SchisandraOssUpBO schisandraOssUpBO = schisandraOssUpDomainService.getUpOssConfig(userId);
|
SchisandraOssUpBO schisandraOssUpBO = schisandraOssUpDomainService.getUpOssConfig(userId);
|
||||||
SchisandraOssUpDTO schisandraOssUpDTO = SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssUpBO);
|
SchisandraOssUpDTO schisandraOssUpDTO = SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssUpBO);
|
||||||
|
log.info("Up oss配置信息获取成功:{}", schisandraOssUpDTO);
|
||||||
if (ObjectUtil.isEmpty(schisandraOssUpDTO)) {
|
if (ObjectUtil.isEmpty(schisandraOssUpDTO)) {
|
||||||
log.error("Up oss配置信息获取失败");
|
log.error("Up oss配置信息获取失败");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String userName = schisandraOssUpDTO.getUserName();
|
String userName = schisandraOssUpDTO.getUserName();
|
||||||
String password = schisandraOssUpDTO.getPassword();
|
String password = schisandraOssUpDTO.getPassword();
|
||||||
|
String bucketName = schisandraOssUpDTO.getBucketName();
|
||||||
|
String basePath = schisandraOssUpDTO.getBasePath();
|
||||||
UpOssConfig upOssConfig = new UpOssConfig();
|
UpOssConfig upOssConfig = new UpOssConfig();
|
||||||
upOssConfig.setUserName(userName);
|
upOssConfig.setUserName(userName);
|
||||||
upOssConfig.setPassword(password);
|
upOssConfig.setPassword(password);
|
||||||
|
upOssConfig.setBucketName(bucketName);
|
||||||
|
upOssConfig.setBasePath(basePath);
|
||||||
|
SpringUtil.registerBean(userId, upOssClient(upOssConfig));
|
||||||
return upOssClient(upOssConfig);
|
return upOssClient(upOssConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private StandardOssClient upOssClient(UpOssConfig upOssConfig) {
|
private UpOssClient upOssClient(UpOssConfig upOssConfig) {
|
||||||
RestManager restManager = restManager(upOssConfig);
|
RestManager restManager = restManager(upOssConfig);
|
||||||
ParallelUploader parallelUploader = parallelUploader(upOssConfig);
|
ParallelUploader parallelUploader = parallelUploader(upOssConfig);
|
||||||
return upOssClient(restManager, parallelUploader, upOssConfig);
|
return upOssClient(restManager, parallelUploader, upOssConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StandardOssClient upOssClient(RestManager restManager, ParallelUploader parallelUploader, UpOssConfig upOssConfig) {
|
public UpOssClient upOssClient(RestManager restManager, ParallelUploader parallelUploader, UpOssConfig upOssConfig) {
|
||||||
return new UpOssClient(restManager, parallelUploader, upOssConfig);
|
return new UpOssClient(restManager, parallelUploader, upOssConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,8 @@ public class SchisandraOssTencentBO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地域
|
* 地域
|
||||||
*/
|
*/
|
||||||
|
@@ -55,7 +55,11 @@ public class SchisandraOssTencent implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@Column("secret_key")
|
@Column("secret_key")
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Column("app_id")
|
||||||
|
private String appId;
|
||||||
/**
|
/**
|
||||||
* 地域
|
* 地域
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user