fix: 上传修复
This commit is contained in:
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -261,12 +262,16 @@ public class SchisandraOssMinioController {
|
||||
* @author zlg
|
||||
* @date: 2024/6/26 14:34
|
||||
*/
|
||||
@PostMapping("uploadFile")
|
||||
public Result<Object> uploadMinioFile(@RequestParam String userId, @RequestParam MultipartFile file, @RequestParam String path, @RequestParam String bucket) throws IOException {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(path, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(file, "不能为空");
|
||||
@PostMapping(value = "uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public Result<Object> uploadMinioFile(SchisandraOssMinioDTO schisandraOssMinioDTO) throws IOException {
|
||||
String path=schisandraOssMinioDTO.getPath();
|
||||
MultipartFile file=schisandraOssMinioDTO.getMultipartFile();
|
||||
String bucket=schisandraOssMinioDTO.getBucketName();
|
||||
String userId=schisandraOssMinioDTO.getUserId();
|
||||
Preconditions.checkNotNull(path, "path不能为空");
|
||||
Preconditions.checkNotNull(file, "file不能为空");
|
||||
Preconditions.checkNotNull(bucket, "bucket不能为空");
|
||||
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||
if (path.lastIndexOf("") == path.length() - 1) {
|
||||
path=path+file.getName();
|
||||
}else{
|
||||
|
@@ -2,6 +2,7 @@ package com.schisandra.oss.application.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -15,6 +16,9 @@ import java.util.Date;
|
||||
@Data
|
||||
public class SchisandraOssMinioDTO implements Serializable {
|
||||
|
||||
private MultipartFile multipartFile;
|
||||
private String path;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
Reference in New Issue
Block a user