This commit is contained in:
77
2024-05-20 12:32:57 +08:00
parent 5bfdde942c
commit 6970319697
9 changed files with 46 additions and 9 deletions

View File

@@ -137,6 +137,24 @@ public class OssClient {
}
}
public UploadResult uploadFile(byte[] data, String tenantPrefix, String suffix, String contentType) {
return upload(data, getPath(properties.getPrefix(),tenantPrefix, suffix), contentType);
}
private String getPath(String prefix,String tenantPrefix, String suffix) {
// 生成uuid
String uuid = IdUtil.fastSimpleUUID();
// 文件路径
String path = DateUtils.datePath() + "/" + uuid;
if(StringUtils.isNotBlank(tenantPrefix)){
path = tenantPrefix + "/" + path;
}
if (StringUtils.isNotBlank(prefix)) {
path = prefix + "/" + path;
}
return path + suffix;
}
public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) {
return upload(data, getPath(properties.getPrefix(), suffix), contentType);
}