|
|
@@ -10,7 +10,6 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -40,18 +39,15 @@ public class OssUtils {
|
|
|
private String dir;
|
|
|
public VaultsResponse<String> uploadOneFile(MultipartFile dto, Long orderId) {
|
|
|
try {
|
|
|
- return uploadOneFile(dto,orderId,null,dto.getInputStream());
|
|
|
+ return uploadOneFile(dto,orderId,dto.getInputStream());
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public VaultsResponse<String> uploadOneFile(MultipartFile dto, Long orderId, InputStream inputStream) {
|
|
|
- return uploadOneFile(dto,orderId,null,inputStream);
|
|
|
- }
|
|
|
|
|
|
- public VaultsResponse<String> uploadOneFile(MultipartFile dto, Long orderId,File file, InputStream inputStream) {
|
|
|
+ public VaultsResponse<String> uploadOneFile(MultipartFile dto, Long orderId,InputStream inputStream) {
|
|
|
// 创建OSSClient实例。
|
|
|
|
|
|
log.info("开始上传===");
|
|
|
@@ -69,15 +65,7 @@ public class OssUtils {
|
|
|
String dirStr = dir+format.format(new Date());
|
|
|
String fileName = dirStr+"/S"+orderId+"N-"+ CgpTool.generateUUID() +suffix;
|
|
|
// 创建PutObject请求。
|
|
|
- log.info("Size=="+dto.getSize()/1024L/1024L);
|
|
|
- if(suffix.indexOf("mp4") != -1 && (dto.getSize() /1024L/1024L >3L) && file != null){
|
|
|
- File outFile = this.compressVideo(file);
|
|
|
- inputStream = new FileInputStream(outFile);
|
|
|
- outFile.delete();
|
|
|
- }
|
|
|
-
|
|
|
ossClient.putObject(bucketName, fileName, inputStream);
|
|
|
-
|
|
|
String url = "https://" + bucketName + "." + endPoint + "/" + fileName;
|
|
|
// System.out.println(url);
|
|
|
log.info("结束上传===");
|
|
|
@@ -150,7 +138,6 @@ public class OssUtils {
|
|
|
public File generateCover(File inputFile) {
|
|
|
log.info("视频截图开始==="+inputFile.getName());
|
|
|
try {
|
|
|
-
|
|
|
// 创建ProcessBuilder对象
|
|
|
log.info("输入路径==="+inputFile.getAbsolutePath());
|
|
|
// 截图保存位置
|