|
|
|
@@ -31,6 +31,7 @@ import com.iformall.video.aliyun.config.AliyunVideoConfig; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import com.aliyuncs.exceptions.ClientException; |
|
|
|
import com.aliyuncs.http.FormatType; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
public class AliyunVedioServer { |
|
|
|
@@ -84,7 +85,7 @@ public class AliyunVedioServer { |
|
|
|
String accessKeyId = uploadAuth.getString("AccessKeyId"); |
|
|
|
String accessKeySecret = uploadAuth.getString("AccessKeySecret"); |
|
|
|
String securityToken = uploadAuth.getString("SecurityToken"); |
|
|
|
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); |
|
|
|
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret,securityToken); |
|
|
|
return new OssUploadClient(bucket, endpoint, fileName, client); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -100,7 +101,7 @@ public class AliyunVedioServer { |
|
|
|
String accessKeyId = uploadAuth.getString("AccessKeyId"); |
|
|
|
String accessKeySecret = uploadAuth.getString("AccessKeySecret"); |
|
|
|
String securityToken = uploadAuth.getString("SecurityToken"); |
|
|
|
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); |
|
|
|
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret,securityToken); |
|
|
|
return new OssUploadClient(bucket, endpoint, fileName, client); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -119,7 +120,7 @@ public class AliyunVedioServer { |
|
|
|
// 上传文件。 |
|
|
|
|
|
|
|
try { |
|
|
|
PutObjectResult result = ossClient.getOssClient().putObject(new PutObjectRequest(ossClient.getBucket(), localFile, new File(localFile)). |
|
|
|
PutObjectResult result = ossClient.getOssClient().putObject(new PutObjectRequest(ossClient.getBucket(), ossClient.getFileName(), new File(localFile)). |
|
|
|
<PutObjectRequest>withProgressListener(new PutObjectProgressListener(redisTemplate,response.getVideoId(),localFile))); |
|
|
|
}catch(Exception e) { |
|
|
|
String msg = e.getLocalizedMessage(); |
|
|
|
@@ -128,7 +129,7 @@ public class AliyunVedioServer { |
|
|
|
try { |
|
|
|
RefreshUploadVideoResponse refrshResoponse = refreshUploadVideo(config,response.getVideoId()); |
|
|
|
ossClient1 = initOssClient(refrshResoponse); |
|
|
|
ossClient1.getOssClient().putObject(new PutObjectRequest(ossClient1.getBucket(), localFile, new File(localFile)). |
|
|
|
ossClient1.getOssClient().putObject(new PutObjectRequest(ossClient1.getBucket(), ossClient1.getFileName(), new File(localFile)). |
|
|
|
<PutObjectRequest>withProgressListener(new PutObjectProgressListener(redisTemplate,refrshResoponse.getVideoId(),localFile))); |
|
|
|
} catch (Exception e1) { |
|
|
|
UploadCacheHelper.cacheError(redisTemplate, response.getVideoId()); |
|
|
|
@@ -149,7 +150,10 @@ public class AliyunVedioServer { |
|
|
|
|
|
|
|
public static RefreshUploadVideoResponse refreshUploadVideo(AliyunVideoConfig config,String videoId) throws Exception { |
|
|
|
RefreshUploadVideoRequest request = new RefreshUploadVideoRequest(); |
|
|
|
request.setVideoId(videoId); |
|
|
|
request.setVideoId("VideoId"); |
|
|
|
request.setAcceptFormat(FormatType.JSON); |
|
|
|
request.setSysReadTimeout(1000); |
|
|
|
request.setSysConnectTimeout(1000); |
|
|
|
DefaultAcsClient client = initVodClient(config); |
|
|
|
return client.getAcsResponse(request); |
|
|
|
} |
|
|
|
|