@ -1,5 +1,7 @@
|
||||
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.OSSObject;
|
||||
import com.stdiet.common.config.AliyunOSSConfig;
|
||||
@ -7,9 +9,6 @@ import com.stdiet.common.utils.StringUtils;
|
||||
import com.stdiet.common.utils.file.FileUtils;
|
||||
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.HttpServletResponse;
|
||||
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_prefix2 = "https://v.stdiet.top";
|
||||
|
||||
public static OSS getOssClient() {
|
||||
return new OSSClientBuilder().build(AliyunOSSConfig.EndPoint, AliyunOSSConfig.AccessKeyID, AliyunOSSConfig.AccessKeySecret);
|
||||
@ -83,6 +83,7 @@ public class AliyunOSSUtils {
|
||||
|
||||
/**
|
||||
* MultipartFile2File
|
||||
*
|
||||
* @param multipartFile
|
||||
* @return
|
||||
*/
|
||||
@ -122,6 +123,7 @@ public class AliyunOSSUtils {
|
||||
|
||||
/**
|
||||
* 上传文件流
|
||||
*
|
||||
* @param prefix 路径的前缀路径目录
|
||||
* @param oranFileName 上传到服务器上的文件路径和名称
|
||||
* @param file 来自本地的文件或者文件流
|
||||
@ -152,6 +154,7 @@ public class AliyunOSSUtils {
|
||||
|
||||
/**
|
||||
* 上传文件流
|
||||
*
|
||||
* @param prefix 路径的前缀路径目录
|
||||
* @param oranFileName 上传到服务器上的文件路径和名称
|
||||
* @param file 来自本地的文件或者文件流
|
||||
@ -230,7 +233,6 @@ public class AliyunOSSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileUrl
|
||||
* @return
|
||||
*/
|
||||
@ -252,7 +254,6 @@ public class AliyunOSSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileUrlList
|
||||
* @return
|
||||
*/
|
||||
@ -279,15 +280,15 @@ public class AliyunOSSUtils {
|
||||
|
||||
/**
|
||||
* 判断是否为阿里云OSS路径格式
|
||||
*
|
||||
* @param fileUrl
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class VideoResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -26,47 +27,11 @@ public class VideoResponse implements Serializable {
|
||||
// 播放等级
|
||||
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) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public Integer getPlayNum() {
|
||||
return playNum;
|
||||
}
|
||||
|
||||
public void setPlayNum(Integer playNum) {
|
||||
this.playNum = playNum;
|
||||
if (StringUtils.isNotEmpty(coverUrl)) {
|
||||
this.coverUrl = AliyunOSSUtils.generatePresignedUrl(coverUrl);
|
||||
} else {
|
||||
this.coverUrl = AliyunVideoUtils.getVideoCoverUrl(this.videoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user