fix: 上传修复

This commit is contained in:
zlg
2024-07-19 09:27:08 +08:00
parent 4e7b60af25
commit 49799a2549
2 changed files with 15 additions and 6 deletions

View File

@@ -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{

View File

@@ -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;
/**
*
*/