|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.fr.plugin.file.submit.oss.fun; |
|
|
|
package com.fr.plugin.file.submit.oss.fun; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.aliyun.oss.OSS; |
|
|
|
import com.aliyun.oss.OSSClient; |
|
|
|
import com.aliyun.oss.OSSClient; |
|
|
|
import com.fr.cache.Attachment; |
|
|
|
import com.fr.cache.Attachment; |
|
|
|
import com.fr.general.FArray; |
|
|
|
import com.fr.general.FArray; |
|
|
@ -14,7 +15,7 @@ import java.io.ByteArrayInputStream; |
|
|
|
|
|
|
|
|
|
|
|
public class OssUpload { |
|
|
|
public class OssUpload { |
|
|
|
|
|
|
|
|
|
|
|
public static void upload(Calculator calculator, OSSClient ossClient, OssSubmitTargetConfig submitTargetConfig) |
|
|
|
public static void upload(Calculator calculator, OSS ossClient, OssSubmitTargetConfig submitTargetConfig) |
|
|
|
throws Exception { |
|
|
|
throws Exception { |
|
|
|
OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets(); |
|
|
|
OssSubmitTarget[] submitTargets = submitTargetConfig.getSubmitTargets(); |
|
|
|
for (OssSubmitTarget target : submitTargets) { |
|
|
|
for (OssSubmitTarget target : submitTargets) { |
|
|
@ -28,7 +29,7 @@ public class OssUpload { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void uploadFile(OSSClient ossClient, String bucket, Object file, String directory, |
|
|
|
private static void uploadFile(OSS ossClient, String bucket, Object file, String directory, |
|
|
|
String newFileName) { |
|
|
|
String newFileName) { |
|
|
|
if (file instanceof FRFile) { |
|
|
|
if (file instanceof FRFile) { |
|
|
|
uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName), |
|
|
|
uploadSingleFile(ossClient, bucket, directory, combineName(((FRFile) file).getFileName(), newFileName), |
|
|
@ -50,7 +51,7 @@ public class OssUpload { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void uploadSingleFile(OSSClient ossClient, String bucket, String directory, String newFileName, |
|
|
|
private static void uploadSingleFile(OSS ossClient, String bucket, String directory, String newFileName, |
|
|
|
byte[] bytes) { |
|
|
|
byte[] bytes) { |
|
|
|
// if (ArrayUtils.isEmpty(bytes)) {
|
|
|
|
// if (ArrayUtils.isEmpty(bytes)) {
|
|
|
|
// throw new RuntimeException(I18nKit.getLocText("Plugin-File_Submit_Oss_Failed", newFileName));
|
|
|
|
// throw new RuntimeException(I18nKit.getLocText("Plugin-File_Submit_Oss_Failed", newFileName));
|
|
|
|