mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-31 02:23:43 +00:00
调整阿里云oss的包结构
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
<module>udf-starter-amqp-rabbitmq</module>
|
||||
<module>udf-starter-file</module>
|
||||
<module>udf-starter-file-aliyun-oss</module>
|
||||
<module>udf-starter-file-aliyun-oss-api</module>
|
||||
<module>udf-starter-mail</module>
|
||||
<module>udf-starter-scheduler</module>
|
||||
<module>udf-starter-scheduler-client</module>
|
||||
@@ -105,6 +106,12 @@
|
||||
<artifactId>udf-starter-file-aliyun-oss</artifactId>
|
||||
<version>${udf-starter.version}</version>
|
||||
</dependency>
|
||||
<!-- udf-starter-file-aliyun-oss-api -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-file-aliyun-oss-api</artifactId>
|
||||
<version>${udf-starter.version}</version>
|
||||
</dependency>
|
||||
<!-- udf-starter-mail -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.itkk.udf.core.domain.aliyun.oss;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DownloadInfo
|
||||
*/
|
||||
@ApiModel(description = "文件下载信息")
|
||||
@Data
|
||||
public class DownloadInfo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "下载ID", required = true, dataType = "string")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* status
|
||||
*/
|
||||
@ApiModelProperty(value = "下载状态 ( 1 : 待执行 , 2 : 执行中 , 3 : 执行完成 , 4 : 执行错误 )", required = true, dataType = "int")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* objectKey
|
||||
*/
|
||||
@ApiModelProperty(value = "阿里云OSS的objectKey", required = true, dataType = "string")
|
||||
private String objectKey;
|
||||
|
||||
/**
|
||||
* errorMsg
|
||||
*/
|
||||
@ApiModelProperty(value = "错误信息", required = true, dataType = "string")
|
||||
private String errorMsg;
|
||||
}
|
||||
+3
-3
@@ -4,11 +4,11 @@
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.file.aliyun.oss;
|
||||
package org.itkk.udf.file.aliyun.oss.api;
|
||||
|
||||
import lombok.Data;
|
||||
import org.itkk.udf.file.aliyun.oss.meta.AliyunOssAccessMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.meta.AliyunOssPathMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.api.meta.AliyunOssAccessMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.api.meta.AliyunOssPathMeta;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+28
-4
@@ -1,4 +1,4 @@
|
||||
package org.itkk.udf.file.aliyun.oss;
|
||||
package org.itkk.udf.file.aliyun.oss.api;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.common.utils.BinaryUtil;
|
||||
@@ -6,12 +6,13 @@ import com.aliyun.oss.model.PolicyConditions;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.itkk.udf.core.ApplicationConfig;
|
||||
import org.itkk.udf.core.exception.ParameterValidException;
|
||||
import org.itkk.udf.file.aliyun.oss.domain.PolicyResult;
|
||||
import org.itkk.udf.file.aliyun.oss.meta.AliyunOssAccessMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.meta.AliyunOssPathMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.api.domain.PolicyResult;
|
||||
import org.itkk.udf.file.aliyun.oss.api.meta.AliyunOssAccessMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.api.meta.AliyunOssPathMeta;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.sql.Date;
|
||||
@@ -176,4 +177,27 @@ public class OssWarpper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param code code
|
||||
* @param file file
|
||||
*/
|
||||
public void uploadFile(String code, File file) {
|
||||
//判空
|
||||
if (!aliyunOssProperties.getAuth().containsKey(code) || !aliyunOssProperties.getPath().containsKey(code)) {
|
||||
throw new ParameterValidException("aliyun oss code:" + code + "未定义", null);
|
||||
}
|
||||
//获得认证信息 和 路径信息
|
||||
AliyunOssAccessMeta auth = aliyunOssProperties.getAuth().get(code);
|
||||
AliyunOssPathMeta path = aliyunOssProperties.getPath().get(code);
|
||||
//实例化oss对象
|
||||
OSSClient client = new OSSClient(auth.getEndPoint(), auth.getAccessId(), auth.getAccessKey());
|
||||
try {
|
||||
client.putObject(path.getBucketName(), file.getName(), file);
|
||||
} finally {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package org.itkk.udf.file.aliyun.oss.domain;
|
||||
package org.itkk.udf.file.aliyun.oss.api.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.itkk.udf.file.aliyun.oss.meta.AliyunOssPathMeta;
|
||||
import org.itkk.udf.file.aliyun.oss.api.meta.AliyunOssPathMeta;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.file.aliyun.oss.meta;
|
||||
package org.itkk.udf.file.aliyun.oss.api.meta;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.file.aliyun.oss.meta;
|
||||
package org.itkk.udf.file.aliyun.oss.api.meta;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -20,11 +20,10 @@
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-core</artifactId>
|
||||
</dependency>
|
||||
<!-- aliyun-sdk-oss -->
|
||||
<!-- udf-starter-file-aliyun-oss-api -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun-sdk-oss.version}</version>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-file-aliyun-oss-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@
|
||||
package org.itkk.udf.file.aliyun.oss.web;
|
||||
|
||||
import org.itkk.udf.core.RestResponse;
|
||||
import org.itkk.udf.file.aliyun.oss.OssWarpper;
|
||||
import org.itkk.udf.core.domain.aliyun.oss.OssParam;
|
||||
import org.itkk.udf.file.aliyun.oss.domain.PolicyResult;
|
||||
import org.itkk.udf.file.aliyun.oss.api.OssWarpper;
|
||||
import org.itkk.udf.file.aliyun.oss.api.domain.PolicyResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.itkk.udf.core.RestResponse;
|
||||
import org.itkk.udf.core.domain.aliyun.oss.OssParam;
|
||||
import org.itkk.udf.file.aliyun.oss.domain.PolicyResult;
|
||||
import org.itkk.udf.file.aliyun.oss.api.domain.PolicyResult;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
Reference in New Issue
Block a user