Commit 883fcf97 by 章家宝

fixbug:阿里云上传图片的时候在图片后缀加上格式化参数

1 parent e4da02fb
......@@ -5,12 +5,10 @@ import com.aliyun.oss.model.*;
import jakarta.annotation.Nullable;
import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import org.summerframework.storage.FileStorageException;
import org.summerframework.storage.StorageService;
import org.summerframework.storage.domain.FileInfo;
import org.summerframework.storage.platform.AbstractStorageService;
......@@ -285,8 +283,13 @@ public class AliyunOssService extends AbstractStorageService {
// 执行上传
ossClient.putObject(putObjectRequest);
Map<String, String> parameter = null;
if (isImageFile(fileInfo.getName())) {
parameter = new HashMap<>();
parameter.put("x-oss-process", "image/format,jpg");
}
// 设置文件信息
fileInfo.setUrl(getFileUrl(fileInfo.getFilePath()));
fileInfo.setUrl(getFileUrl(fileInfo.getFilePath(), null, parameter));
// 获取文件大小
OSSObject ossObject = ossClient.getObject(bucketName, filePath);
......@@ -295,7 +298,7 @@ public class AliyunOssService extends AbstractStorageService {
String thumbPath = this.thumbnails(fileInfo.getName(), filePath);
if (StringUtils.isNotBlank(thumbPath)) {
fileInfo.setThumbPath(thumbPath);
fileInfo.setThumbUrl(this.getFileUrl(thumbPath));
fileInfo.setThumbUrl(this.getFileUrl(thumbPath, null, parameter));
}
} catch (Exception e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!