|
|
|
@ -8,9 +8,11 @@ import com.ruoyi.file.utils.FileUploadUtils;
|
|
|
|
|
import io.minio.MinioClient;
|
|
|
|
|
import io.minio.PutObjectArgs;
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Minio 文件存储
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
@ -23,8 +25,8 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
|
|
|
|
private MinioClient client;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 本地文件上传接口
|
|
|
|
|
*
|
|
|
|
|
* Minio文件上传接口
|
|
|
|
|
*
|
|
|
|
|
* @param file 上传的文件
|
|
|
|
|
* @return 访问地址
|
|
|
|
|
* @throws Exception
|
|
|
|
@ -33,13 +35,15 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
|
|
|
|
public String uploadFile(MultipartFile file) throws Exception
|
|
|
|
|
{
|
|
|
|
|
String fileName = FileUploadUtils.extractFilename(file);
|
|
|
|
|
InputStream inputStream = file.getInputStream();
|
|
|
|
|
PutObjectArgs args = PutObjectArgs.builder()
|
|
|
|
|
.bucket(minioConfig.getBucketName())
|
|
|
|
|
.object(fileName)
|
|
|
|
|
.stream(file.getInputStream(), file.getSize(), -1)
|
|
|
|
|
.stream(inputStream, file.getSize(), -1)
|
|
|
|
|
.contentType(file.getContentType())
|
|
|
|
|
.build();
|
|
|
|
|
client.putObject(args);
|
|
|
|
|
inputStream.close();
|
|
|
|
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|