|
@@ -9,7 +9,6 @@ import org.jeecg.modules.wps.util.file.FileType;
|
|
import org.jeecg.modules.wps.util.file.FileTypeJudge;
|
|
import org.jeecg.modules.wps.util.file.FileTypeJudge;
|
|
import org.jeecg.modules.wps.util.file.FileUtil;
|
|
import org.jeecg.modules.wps.util.file.FileUtil;
|
|
import org.jeecg.modules.wps.util.upload.ResFileDTO;
|
|
import org.jeecg.modules.wps.util.upload.ResFileDTO;
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -22,62 +21,26 @@ import java.util.*;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class WpsOSSUtil {
|
|
public class WpsOSSUtil {
|
|
- private static String fileUrlPrefix;
|
|
|
|
|
|
+ public static final String fileUrlPrefix = "https://ctop-media.oss-cn-beijing.aliyuncs.com/";
|
|
/**
|
|
/**
|
|
* 阿里云API的bucket名称
|
|
* 阿里云API的bucket名称
|
|
*/
|
|
*/
|
|
- private static String bucketName;
|
|
|
|
- private static String diskName;
|
|
|
|
- private static String regionId;
|
|
|
|
|
|
+ public static final String bucketName = "ctop-media";
|
|
|
|
+ public static final String diskName = "script-lib/wps/";
|
|
|
|
+ public static final String regionId = "cn-bejing";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 阿里云API的内或外网域名
|
|
* 阿里云API的内或外网域名
|
|
*/
|
|
*/
|
|
- private static String endpoint;
|
|
|
|
|
|
+ public static final String endpoint = "http://oss-cn-beijing.aliyuncs.com";
|
|
/**
|
|
/**
|
|
* 阿里云API的密钥Access Key ID
|
|
* 阿里云API的密钥Access Key ID
|
|
*/
|
|
*/
|
|
- private static String accessKey;
|
|
|
|
|
|
+ public static final String accessKey = "LTAIbNbqWzSOklQV";
|
|
/**
|
|
/**
|
|
* 阿里云API的密钥Access Key Secret
|
|
* 阿里云API的密钥Access Key Secret
|
|
*/
|
|
*/
|
|
- private static String accessSecret;
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.file_url_prefix}")
|
|
|
|
- public static void setFileUrlPrefix(String fileUrlPrefix) {
|
|
|
|
- WpsOSSUtil.fileUrlPrefix = fileUrlPrefix;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.disk_name}")
|
|
|
|
- public static void setDiskName(String diskName) {
|
|
|
|
- WpsOSSUtil.diskName = diskName;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.region_Id}")
|
|
|
|
- public static void setRegionId(String regionId) {
|
|
|
|
- WpsOSSUtil.regionId = regionId;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.bucket_name}")
|
|
|
|
- public void setBucketName(String bucketName) {
|
|
|
|
- WpsOSSUtil.bucketName = bucketName;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.access_key}")
|
|
|
|
- public void setAccessKey(String accessKey) {
|
|
|
|
- WpsOSSUtil.accessKey = accessKey;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.access_secret}")
|
|
|
|
- public void setAccessSecret(String accessSecret) {
|
|
|
|
- WpsOSSUtil.accessSecret = accessSecret;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Value("${wps.oss.endpoint}")
|
|
|
|
- public void setEndpoint(String endpoint) {
|
|
|
|
- WpsOSSUtil.endpoint = endpoint;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ public static final String accessSecret = "1rkPz7JNoXk8sJevPaeYHWqfkQXBGh";
|
|
|
|
|
|
private static OSSClient getOSSClient(){
|
|
private static OSSClient getOSSClient(){
|
|
return new OSSClient(endpoint,accessKey, accessSecret);
|
|
return new OSSClient(endpoint,accessKey, accessSecret);
|
|
@@ -284,7 +247,6 @@ public class WpsOSSUtil {
|
|
OSSClient client = getOSSClient();
|
|
OSSClient client = getOSSClient();
|
|
InputStream is = new FileInputStream(file);
|
|
InputStream is = new FileInputStream(file);
|
|
String fileName = file.getName();
|
|
String fileName = file.getName();
|
|
- long fileSize = file.length();
|
|
|
|
//创建上传Object的Metadata
|
|
//创建上传Object的Metadata
|
|
ObjectMetadata metadata = new ObjectMetadata();
|
|
ObjectMetadata metadata = new ObjectMetadata();
|
|
metadata.setContentLength(is.available());
|
|
metadata.setContentLength(is.available());
|