调整oss
This commit is contained in:
parent
1af737fe87
commit
f6652e1a52
@ -1,5 +1,7 @@
|
|||||||
package com.stdiet.common.utils.oss;
|
package com.stdiet.common.utils.oss;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
import com.aliyun.oss.model.GetObjectRequest;
|
import com.aliyun.oss.model.GetObjectRequest;
|
||||||
import com.aliyun.oss.model.OSSObject;
|
import com.aliyun.oss.model.OSSObject;
|
||||||
import com.stdiet.common.config.AliyunOSSConfig;
|
import com.stdiet.common.config.AliyunOSSConfig;
|
||||||
@ -7,9 +9,6 @@ import com.stdiet.common.utils.StringUtils;
|
|||||||
import com.stdiet.common.utils.file.FileUtils;
|
import com.stdiet.common.utils.file.FileUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import com.aliyun.oss.OSS;
|
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -25,6 +24,7 @@ public class AliyunOSSUtils {
|
|||||||
|
|
||||||
//默认文件路径前缀
|
//默认文件路径前缀
|
||||||
private static final String default_prefix = "https://stdiet.oss-cn-shenzhen.aliyuncs.com";
|
private static final String default_prefix = "https://stdiet.oss-cn-shenzhen.aliyuncs.com";
|
||||||
|
private static final String default_prefix2 = "https://v.stdiet.top";
|
||||||
|
|
||||||
public static OSS getOssClient() {
|
public static OSS getOssClient() {
|
||||||
return new OSSClientBuilder().build(AliyunOSSConfig.EndPoint, AliyunOSSConfig.AccessKeyID, AliyunOSSConfig.AccessKeySecret);
|
return new OSSClientBuilder().build(AliyunOSSConfig.EndPoint, AliyunOSSConfig.AccessKeyID, AliyunOSSConfig.AccessKeySecret);
|
||||||
@ -83,6 +83,7 @@ public class AliyunOSSUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* MultipartFile2File
|
* MultipartFile2File
|
||||||
|
*
|
||||||
* @param multipartFile
|
* @param multipartFile
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -122,6 +123,7 @@ public class AliyunOSSUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件流
|
* 上传文件流
|
||||||
|
*
|
||||||
* @param prefix 路径的前缀路径目录
|
* @param prefix 路径的前缀路径目录
|
||||||
* @param oranFileName 上传到服务器上的文件路径和名称
|
* @param oranFileName 上传到服务器上的文件路径和名称
|
||||||
* @param file 来自本地的文件或者文件流
|
* @param file 来自本地的文件或者文件流
|
||||||
@ -152,6 +154,7 @@ public class AliyunOSSUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件流
|
* 上传文件流
|
||||||
|
*
|
||||||
* @param prefix 路径的前缀路径目录
|
* @param prefix 路径的前缀路径目录
|
||||||
* @param oranFileName 上传到服务器上的文件路径和名称
|
* @param oranFileName 上传到服务器上的文件路径和名称
|
||||||
* @param file 来自本地的文件或者文件流
|
* @param file 来自本地的文件或者文件流
|
||||||
@ -230,7 +233,6 @@ public class AliyunOSSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param fileUrl
|
* @param fileUrl
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -252,7 +254,6 @@ public class AliyunOSSUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param fileUrlList
|
* @param fileUrlList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -279,15 +280,15 @@ public class AliyunOSSUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否为阿里云OSS路径格式
|
* 判断是否为阿里云OSS路径格式
|
||||||
|
*
|
||||||
* @param fileUrl
|
* @param fileUrl
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isAliyunUrl(String fileUrl) {
|
public static boolean isAliyunUrl(String fileUrl) {
|
||||||
return StringUtils.isNotEmpty(fileUrl) && fileUrl.startsWith(default_prefix);
|
return StringUtils.isNotEmpty(fileUrl) && (fileUrl.startsWith(default_prefix) || fileUrl.startsWith(default_prefix2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param fileUrlList
|
* @param fileUrlList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class VideoResponse implements Serializable {
|
public class VideoResponse implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -26,47 +27,11 @@ public class VideoResponse implements Serializable {
|
|||||||
// 播放等级
|
// 播放等级
|
||||||
private Integer playLevel;
|
private Integer playLevel;
|
||||||
|
|
||||||
public void setPlayLevel(Integer playLevel) {
|
|
||||||
this.playLevel = playLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPlayLevel() {
|
|
||||||
return playLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVideoId() {
|
|
||||||
return videoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideoId(String videoId) {
|
|
||||||
this.videoId = videoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCoverUrl() {
|
|
||||||
if (StringUtils.isNotEmpty(this.coverUrl)) {
|
|
||||||
return AliyunOSSUtils.generatePresignedUrl(this.coverUrl);
|
|
||||||
} else {
|
|
||||||
return AliyunVideoUtils.getVideoCoverUrl(this.videoId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCoverUrl(String coverUrl) {
|
public void setCoverUrl(String coverUrl) {
|
||||||
this.coverUrl = coverUrl;
|
if (StringUtils.isNotEmpty(coverUrl)) {
|
||||||
}
|
this.coverUrl = AliyunOSSUtils.generatePresignedUrl(coverUrl);
|
||||||
|
} else {
|
||||||
public Integer getPlayNum() {
|
this.coverUrl = AliyunVideoUtils.getVideoCoverUrl(this.videoId);
|
||||||
return playNum;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayNum(Integer playNum) {
|
|
||||||
this.playNum = playNum;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user