add 新增了oss指定文件夹上传

This commit is contained in:
Jerome 2022-08-19 23:22:31 +08:00
parent d1681dc18c
commit 7f4df15c34

View File

@ -118,6 +118,10 @@ public class OssClient {
return upload(inputStream, getPath(properties.getPrefix(), suffix), contentType);
}
public UploadResult uploadByFolder(byte[] data, String suffix, String contentType,String folder) {
return upload(data, getFolderPath(properties.getPrefix(),folder, suffix), contentType);
}
/**
* 获取文件元数据
*
@ -157,6 +161,24 @@ public class OssClient {
return path + suffix;
}
public String getFolderPath(String prefix, String folder, String suffix) {
// 生成uuid
String uuid = IdUtil.fastSimpleUUID();
// 文件路径
String path = DateUtils.datePath() + "/" + uuid;
if(StringUtils.isNotBlank(prefix) && StringUtils.isNotBlank(folder)){
path = prefix + "/" + folder + "/" + path;
}else{
if(StringUtils.isNotBlank(prefix)){
path = folder + "/" + path;
}
if(StringUtils.isNotBlank(folder)){
path = prefix + "/" + path;
}
}
return path + suffix;
}
public String getConfigKey() {
return configKey;