代码调整
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.njcn.oss.utils;
|
||||
|
||||
import cn.hutool.core.text.CharPool;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -75,19 +78,19 @@ public class FileStorageUtil {
|
||||
* 上传InputStream流,
|
||||
* @author hongawen
|
||||
* @date 2023/3/7 22:48
|
||||
* @param fileStream 文件源
|
||||
* @param inputStream 文件源
|
||||
* @param dir 服务器文件存放路径
|
||||
* @param fileName 原始文件名
|
||||
*/
|
||||
public String uploadStream(FileInputStream fileStream, String dir, String fileName) {
|
||||
public String uploadStream(InputStream inputStream, String dir, String fileName) {
|
||||
String filePath;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(fileName);
|
||||
obsUtil.uploadStream(fileStream, filePath);
|
||||
obsUtil.uploadStream(inputStream, filePath);
|
||||
} else {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.uploadStream(fileStream, minIossProperties.getBucket(), dir, minIoUtils.minFileName(fileName));
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.uploadStream(inputStream, minIossProperties.getBucket(), dir, minIoUtils.minFileName(fileName));
|
||||
filePath = minIoUploadResDTO.getMinFileName();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||
@@ -218,4 +221,6 @@ public class FileStorageUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user