|
@@ -2,11 +2,14 @@ package vip.xiaonuo.disk.util;
|
|
|
|
|
|
|
|
import io.minio.DownloadObjectArgs;
|
|
import io.minio.DownloadObjectArgs;
|
|
|
import io.minio.MinioClient;
|
|
import io.minio.MinioClient;
|
|
|
|
|
+import io.minio.UploadObjectArgs;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@@ -156,16 +159,25 @@ public class PdfUtils {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void uploadToMinio(String filePath, String fileId,String objectName) throws Exception {
|
|
private void uploadToMinio(String filePath, String fileId,String objectName) throws Exception {
|
|
|
- String fileName = new File(filePath).getName();
|
|
|
|
|
-// minioClient.uploadObject(
|
|
|
|
|
-// UploadObjectArgs.builder()
|
|
|
|
|
-// .bucket(bucketName)
|
|
|
|
|
-// .object("converted/"+fileId)
|
|
|
|
|
-// .filename(filePath)
|
|
|
|
|
-// .build());
|
|
|
|
|
- s3MultiThreadMultipartUpload.uploadFile(filePath,fileName);
|
|
|
|
|
|
|
+ // String fileName = new File(filePath).getName();
|
|
|
|
|
+ try {
|
|
|
|
|
+ minioClient.uploadObject(
|
|
|
|
|
+ UploadObjectArgs.builder()
|
|
|
|
|
+ .bucket(bucketName)
|
|
|
|
|
+ .object("converted/"+getCurrentDate()+"/"+objectName)
|
|
|
|
|
+ .filename(fileId)
|
|
|
|
|
+ .contentType("application/pdf")
|
|
|
|
|
+ .build());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException("转换后的pdf上传minio报错=========================》",e);
|
|
|
|
|
+ }
|
|
|
|
|
+ // s3MultiThreadMultipartUpload.uploadFile(filePath,fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+ public String getCurrentDate() {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
+ String currentDate = sdf.format(new Date());
|
|
|
|
|
+ return currentDate;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
private void cleanTempDir(String filePath,String outputPath) {
|
|
private void cleanTempDir(String filePath,String outputPath) {
|
|
|
// File[] files = new File(tempDir).listFiles();
|
|
// File[] files = new File(tempDir).listFiles();
|
|
|
// if (files != null) {
|
|
// if (files != null) {
|