提交 e3493614 作者: 方治民

合并分支 '3.0' 到 'beta'

3.0

查看合并请求 !18
流水线 #2025 已通过 于阶段
in 2 分 58 秒
...@@ -168,6 +168,8 @@ public class UploadProcessServiceImpl implements UploadProcessService { ...@@ -168,6 +168,8 @@ public class UploadProcessServiceImpl implements UploadProcessService {
if (Files.exists(path)) { if (Files.exists(path)) {
// 上传封面图 // 上传封面图
minio.putObject(path.toFile(), getObjectFolder(object)); minio.putObject(path.toFile(), getObjectFolder(object));
// 手动 GC 一次
System.gc();
} }
} }
......
...@@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil; ...@@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
import com.yiring.common.core.Minio; import com.yiring.common.core.Minio;
import com.yiring.common.service.FileManageService; import com.yiring.common.service.FileManageService;
import com.yiring.common.service.UploadProcessService; import com.yiring.common.service.UploadProcessService;
import java.io.InputStream;
import lombok.Cleanup;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -45,7 +47,9 @@ public class FileManageServiceImpl implements FileManageService { ...@@ -45,7 +47,9 @@ public class FileManageServiceImpl implements FileManageService {
// 上传原文件(如果是转换成了 m3u8 hls 文件则不保存原文件) // 上传原文件(如果是转换成了 m3u8 hls 文件则不保存原文件)
String suffix = ".m3u8"; String suffix = ".m3u8";
if (filename.endsWith(suffix) || !object.endsWith(suffix)) { if (filename.endsWith(suffix) || !object.endsWith(suffix)) {
minio.putObject(file.getInputStream(), file.getContentType(), object); @Cleanup
InputStream stream = file.getInputStream();
minio.putObject(stream, file.getContentType(), object);
} }
return minio.getDefaultURI(object); return minio.getDefaultURI(object);
......
...@@ -76,10 +76,8 @@ public class MinioController { ...@@ -76,10 +76,8 @@ public class MinioController {
) )
@PostMapping(value = "uploadBase64Image") @PostMapping(value = "uploadBase64Image")
public Result<String> uploadBase64Image(@NotBlank(message = "图片 Base64 信息不能为空") String base64Image) { public Result<String> uploadBase64Image(@NotBlank(message = "图片 Base64 信息不能为空") String base64Image) {
try {
// 解析 Base64 图片信息 // 解析 Base64 图片信息
ImageInfo image = FileUtils.parseBase64ImageText(base64Image); try (ImageInfo image = FileUtils.parseBase64ImageText(base64Image)) {
// 获取文件信息以及默认存储地址 // 获取文件信息以及默认存储地址
String uuid = IdUtil.getSnowflakeNextIdStr(); String uuid = IdUtil.getSnowflakeNextIdStr();
String object = minio.buildUploadPath( String object = minio.buildUploadPath(
...@@ -106,9 +104,8 @@ public class MinioController { ...@@ -106,9 +104,8 @@ public class MinioController {
@Operation(summary = "文件下载") @Operation(summary = "文件下载")
@GetMapping(value = "download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @GetMapping(value = "download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public void download(HttpServletResponse response, @ParameterObject @Validated DownloadParam param) { public void download(HttpServletResponse response, @ParameterObject @Validated DownloadParam param) {
try { try (GetObjectResponse object = minio.getObject(param.getBucket(), param.getObject())) {
StatObjectResponse statObject = minio.objectStat(param.getBucket(), param.getObject()); StatObjectResponse statObject = minio.objectStat(param.getBucket(), param.getObject());
GetObjectResponse object = minio.getObject(param.getBucket(), param.getObject());
long lastModified = Timestamp.from(statObject.lastModified().toInstant()).getTime(); long lastModified = Timestamp.from(statObject.lastModified().toInstant()).getTime();
FileUtils.download( FileUtils.download(
response, response,
......
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.common.core; package com.yiring.common.core;
import cn.hutool.core.convert.Convert;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -473,6 +474,11 @@ public final class Redis { ...@@ -473,6 +474,11 @@ public final class Redis {
* @return 信息 * @return 信息
*/ */
public String info() { public String info() {
return redisTemplate.execute(connection -> Objects.requireNonNull(connection.info()).toString(), false); Properties info = Objects
.requireNonNull(redisTemplate.getConnectionFactory())
.getConnection()
.serverCommands()
.info();
return Convert.toStr(info);
} }
} }
...@@ -22,7 +22,7 @@ import lombok.NoArgsConstructor; ...@@ -22,7 +22,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ImageInfo implements Serializable { public class ImageInfo implements Serializable, AutoCloseable {
@Serial @Serial
private static final long serialVersionUID = 4042804283860857802L; private static final long serialVersionUID = 4042804283860857802L;
...@@ -61,4 +61,11 @@ public class ImageInfo implements Serializable { ...@@ -61,4 +61,11 @@ public class ImageInfo implements Serializable {
* 图片高度 * 图片高度
*/ */
int height; int height;
@Override
public void close() throws Exception {
if (stream != null) {
stream.close();
}
}
} }
plugins { plugins {
id 'java' id 'java'
// https://start.spring.io // https://start.spring.io
id 'org.springframework.boot' version '3.0.3' id 'org.springframework.boot' version '3.0.4'
id 'org.graalvm.buildtools.native' version '0.9.18' id 'org.graalvm.buildtools.native' version '0.9.18'
// https://plugins.gradle.org/plugin/io.spring.dependency-management // https://plugins.gradle.org/plugin/io.spring.dependency-management
id 'io.spring.dependency-management' version '1.1.0' id 'io.spring.dependency-management' version '1.1.0'
// https://plugins.gradle.org/plugin/com.diffplug.spotless // https://plugins.gradle.org/plugin/com.diffplug.spotless
id "com.diffplug.spotless" version "6.15.0" id "com.diffplug.spotless" version "6.16.0"
} }
ext { ext {
...@@ -14,13 +14,14 @@ ext { ...@@ -14,13 +14,14 @@ ext {
// https://www.npmjs.com/package/prettier // https://www.npmjs.com/package/prettier
prettierVersion = '2.8.4' prettierVersion = '2.8.4'
// https://www.npmjs.com/package/prettier-plugin-java // https://www.npmjs.com/package/prettier-plugin-java
prettierJavaVersion = '2.0.0' prettierJavaVersion = '2.1.0'
// SpringCloud // SpringCloud
// https://start.spring.io/ // https://start.spring.io/
springCloudVersion = '2022.0.1' springCloudVersion = '2022.0.1'
// springBootAdminVersion // springBootAdminVersion
springBootAdminVersion = '3.0.0' // https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-server
springBootAdminVersion = '3.0.1'
// Dependencies // Dependencies
// https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-openapi3-jakarta-spring-boot-starter // https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-openapi3-jakarta-spring-boot-starter
...@@ -30,9 +31,9 @@ ext { ...@@ -30,9 +31,9 @@ ext {
// https://mvnrepository.com/artifact/cn.dev33/sa-token-spring-boot3-starter // https://mvnrepository.com/artifact/cn.dev33/sa-token-spring-boot3-starter
saTokenVersion = '1.34.0' saTokenVersion = '1.34.0'
// https://mvnrepository.com/artifact/cn.hutool/hutool-all // https://mvnrepository.com/artifact/cn.hutool/hutool-all
hutoolVersion = '5.8.12' hutoolVersion = '5.8.15'
// https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 // https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2
fastJsonVersion = '2.0.24' fastJsonVersion = '2.0.25'
// https://mvnrepository.com/artifact/com.xuxueli/xxl-job-core // https://mvnrepository.com/artifact/com.xuxueli/xxl-job-core
xxlJobVersion = '2.3.1' xxlJobVersion = '2.3.1'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
...@@ -41,17 +42,18 @@ ext { ...@@ -41,17 +42,18 @@ ext {
minioVersion = '8.5.2' minioVersion = '8.5.2'
// https://mvnrepository.com/artifact/io.hypersistence/hypersistence-utils-hibernate-60 // https://mvnrepository.com/artifact/io.hypersistence/hypersistence-utils-hibernate-60
hibernateTypesVersion = '3.2.0' hibernateTypesVersion = '3.2.0'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-spatial // https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-spatial
hibernateSpatialVersion = '6.1.7.Final' hibernateSpatialVersion = '6.1.7.Final'
// https://mvnrepository.com/artifact/org.locationtech.jts/jts-core // https://mvnrepository.com/artifact/org.locationtech.jts/jts-core
jtsVersion = '1.19.0' jtsVersion = '1.19.0'
// https://mvnrepository.com/artifact/com.github.liaochong/myexcel // https://mvnrepository.com/artifact/com.github.liaochong/myexcel
myexcelVersion = '4.2.2' myexcelVersion = '4.2.2'
// https://mvnrepository.com/artifact/org.jetbrains/annotations // https://mvnrepository.com/artifact/org.jetbrains/annotations
jetbrainsAnnotationsVersion = '24.0.0' jetbrainsAnnotationsVersion = '24.0.1'
// https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox // https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox
pdfboxVersion = '2.0.27' pdfboxVersion = '2.0.27'
// https://mvnrepository.com/artifact/net.bramp.ffmpeg/ffmpeg // https://mvnrepository.com/artifact/net.bramp.ffmpeg/ffmpeg
// FIXED: ffmpeg 4.x
ffmpegWrapperVersion = '0.7.0' ffmpegWrapperVersion = '0.7.0'
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论