表单提交
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -21,9 +19,11 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -81,6 +81,31 @@ public class FileStorageUtil {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 上传MultipartFile文件,
|
||||
* @author hongawen
|
||||
* @date 2023/3/7 22:48
|
||||
* @param multipartFile 文件源
|
||||
* @param dir 服务器文件存放路径
|
||||
* @param flag 是否保留原始文件名
|
||||
*/
|
||||
public String uploadMultipart(MultipartFile multipartFile, String dir,boolean flag) {
|
||||
String filePath;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(multipartFile.getOriginalFilename());
|
||||
obsUtil.uploadMultipart(multipartFile, filePath);
|
||||
} else {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.upload(multipartFile, minIossProperties.getBucket(), dir,flag);
|
||||
filePath = minIoUploadResDTO.getMinFileName();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 上传InputStream流,
|
||||
* @author hongawen
|
||||
|
||||
Reference in New Issue
Block a user