fixbug 文件上传大小 && 微信https 异常问题
This commit is contained in:
@@ -119,19 +119,21 @@ public class OSSClientUtil {
|
||||
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase();
|
||||
String name = UUIDGenerator.randomUUID() + substring;
|
||||
backUrl = healthDir + name;
|
||||
String uploadUrl = healthDir + name;
|
||||
// 上传文件
|
||||
ossClient.putObject(bucketName, backUrl, multipartFile.getInputStream());
|
||||
ossClient.setObjectAcl(bucketName, backUrl, CannedAccessControlList.PublicRead);
|
||||
ossClient.putObject(bucketName, uploadUrl, multipartFile.getInputStream());
|
||||
ossClient.setObjectAcl(bucketName, uploadUrl, CannedAccessControlList.PublicRead);
|
||||
// 判断是否上传成功
|
||||
boolean uploadResult = ossClient.doesObjectExist(bucketName, backUrl);
|
||||
boolean uploadResult = ossClient.doesObjectExist(bucketName, uploadUrl);
|
||||
|
||||
if (uploadResult) {
|
||||
backUrl = getUploadUrl(name);
|
||||
} else {
|
||||
backUrl = "";
|
||||
}
|
||||
} finally {
|
||||
} catch (Exception ex) {
|
||||
log.error("upload error",ex);
|
||||
}finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
@@ -139,10 +141,12 @@ public class OSSClientUtil {
|
||||
return backUrl;
|
||||
}
|
||||
|
||||
private String getUploadUrl(String fileUrl) {
|
||||
if (!StringUtils.isEmpty(fileUrl)) {
|
||||
String[] split = fileUrl.split("/");
|
||||
return url + this.healthDir + split[split.length - 1];
|
||||
private String getUploadUrl(String fileName) {
|
||||
if (!StringUtils.isEmpty(fileName)) {
|
||||
// String[] split = fileUrl.split("/");
|
||||
// return this.healthDir + split[split.length - 1];
|
||||
String result = "https://api.hongyutiyu.top/fetchFile/" + fileName;
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user