OSSServer调整为CDN访问
This commit is contained in:
@@ -26,6 +26,9 @@ public class OSSServer {
|
|||||||
@Value("${corp.id:null}")
|
@Value("${corp.id:null}")
|
||||||
private String corpId;
|
private String corpId;
|
||||||
|
|
||||||
|
@Value("${cdn.url:null}")
|
||||||
|
private String cdnUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务端上传文件的方法
|
* 服务端上传文件的方法
|
||||||
* ObjectName 为文件存放位置 + 名字,不可包含 bucket
|
* ObjectName 为文件存放位置 + 名字,不可包含 bucket
|
||||||
@@ -38,7 +41,7 @@ public class OSSServer {
|
|||||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName, inputStream);
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName, inputStream);
|
||||||
// 创建PutObject请求。
|
// 创建PutObject请求。
|
||||||
ossClient.putObject(putObjectRequest);
|
ossClient.putObject(putObjectRequest);
|
||||||
return "http://" + bucket + "." + endpoint + "/" + objectName;
|
return cdnUrl + "/partner/" + corpId + "/" + objectName;
|
||||||
} catch (OSSException oe) {
|
} catch (OSSException oe) {
|
||||||
log.error("Caught an OSSException, which means your request made it to OSS, "
|
log.error("Caught an OSSException, which means your request made it to OSS, "
|
||||||
+ "but was rejected with an error response for some reason.");
|
+ "but was rejected with an error response for some reason.");
|
||||||
|
|||||||
@@ -260,13 +260,13 @@ public class FlowServiceImpl implements FlowService {
|
|||||||
ByteArrayOutputStream pdfOut = PassLetterUtils.genPassLetter(partnerName, passCode, verifyCity, passTime);
|
ByteArrayOutputStream pdfOut = PassLetterUtils.genPassLetter(partnerName, passCode, verifyCity, passTime);
|
||||||
//生成的 pdf 通过函内存输入流
|
//生成的 pdf 通过函内存输入流
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfOut.toByteArray());
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(pdfOut.toByteArray());
|
||||||
String passPdfUrl = ossServer.uploadFileServer(inputStream, "partner/passLetter/" + passCode + ".pdf");
|
String passPdfUrl = ossServer.uploadFileServer(inputStream, "passLetter/" + passCode + ".pdf");
|
||||||
//转换为图片
|
//转换为图片
|
||||||
inputStream.reset();
|
inputStream.reset();
|
||||||
ByteArrayOutputStream imageOut = PDFUtils.pdf2Img(inputStream, 2.0f);
|
ByteArrayOutputStream imageOut = PDFUtils.pdf2Img(inputStream, 2.0f);
|
||||||
inputStream = new ByteArrayInputStream(imageOut.toByteArray());
|
inputStream = new ByteArrayInputStream(imageOut.toByteArray());
|
||||||
//上传 OSS
|
//上传 OSS
|
||||||
String passImageUrl = ossServer.uploadFileServer(inputStream, "partner/passLetter/" + passCode + ".png");
|
String passImageUrl = ossServer.uploadFileServer(inputStream, "passLetter/" + passCode + ".png");
|
||||||
//计算有效期截止日期
|
//计算有效期截止日期
|
||||||
DateTime expiryDate = DateUtil.offsetDay(passTime, 60);
|
DateTime expiryDate = DateUtil.offsetDay(passTime, 60);
|
||||||
HyPartnerInterviewDO interviewDO = new HyPartnerInterviewDO();
|
HyPartnerInterviewDO interviewDO = new HyPartnerInterviewDO();
|
||||||
|
|||||||
Reference in New Issue
Block a user