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