|
@@ -20,6 +20,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
+ * oss上传管理Service实现类
|
|
|
* Created by macro on 2018/5/17.
|
|
|
*/
|
|
|
@Service
|
|
@@ -57,10 +58,10 @@ public class OssServiceImpl implements OssService {
|
|
|
// 文件大小
|
|
|
long maxSize = ALIYUN_OSS_MAX_SIZE * 1024 * 1024;
|
|
|
// 回调
|
|
|
-// OssCallbackParam callback = new OssCallbackParam();
|
|
|
-// callback.setCallbackUrl(ALIYUN_OSS_CALLBACK);
|
|
|
-// callback.setCallbackBody("filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}");
|
|
|
-// callback.setCallbackBodyType("application/x-www-form-urlencoded");
|
|
|
+ OssCallbackParam callback = new OssCallbackParam();
|
|
|
+ callback.setCallbackUrl(ALIYUN_OSS_CALLBACK);
|
|
|
+ callback.setCallbackBody("filename=${object}&size=${size}&mimeType=${mimeType}&height=${imageInfo.height}&width=${imageInfo.width}");
|
|
|
+ callback.setCallbackBodyType("application/x-www-form-urlencoded");
|
|
|
// 提交节点
|
|
|
String action = "http://" + ALIYUN_OSS_BUCKET_NAME + "." + ALIYUN_OSS_ENDPOINT;
|
|
|
try {
|
|
@@ -71,13 +72,13 @@ public class OssServiceImpl implements OssService {
|
|
|
byte[] binaryData = postPolicy.getBytes("utf-8");
|
|
|
String policy = BinaryUtil.toBase64String(binaryData);
|
|
|
String signature = ossClient.calculatePostSignature(postPolicy);
|
|
|
-// String callbackData = BinaryUtil.toBase64String(JSONUtil.parse(callback).toString().getBytes("utf-8"));
|
|
|
+ String callbackData = BinaryUtil.toBase64String(JSONUtil.parse(callback).toString().getBytes("utf-8"));
|
|
|
// 返回结果
|
|
|
result.setAccessKeyId(ossClient.getCredentialsProvider().getCredentials().getAccessKeyId());
|
|
|
result.setPolicy(policy);
|
|
|
result.setSignature(signature);
|
|
|
result.setDir(dir);
|
|
|
-// result.setCallback(callbackData);
|
|
|
+ result.setCallback(callbackData);
|
|
|
result.setHost(action);
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("签名生成失败", e);
|