|
|
|
@ -49,14 +49,14 @@ public class TencentUploadServiceImpl implements TencentUploadService {
|
|
|
|
|
map.put("url" + i, imgUrl); |
|
|
|
|
type = 1; |
|
|
|
|
} |
|
|
|
|
} else if (type.equals(4)){ |
|
|
|
|
} else if (type.equals(4)) { |
|
|
|
|
//普通上传
|
|
|
|
|
String s = uploadFile2Cos(file, type); |
|
|
|
|
String imgUrl = getNftImgUrl(s); |
|
|
|
|
//String str1=imgUrl.substring(0, imgUrl.indexOf("?"));
|
|
|
|
|
// map.put("url0",url );
|
|
|
|
|
map.put("url", imgUrl); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
//普通上传
|
|
|
|
|
String s = uploadFile2Cos(file, type); |
|
|
|
|
String imgUrl = getImgUrl(s); |
|
|
|
@ -69,6 +69,20 @@ public class TencentUploadServiceImpl implements TencentUploadService {
|
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> uploadVideo(MultipartFile file) throws IOException { |
|
|
|
|
String originalFilename = FileUploadUtils.extractFilename(file); |
|
|
|
|
String substring = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase(); |
|
|
|
|
Random random = new Random(); |
|
|
|
|
String name = random.nextInt(10000) + System.currentTimeMillis() + substring; |
|
|
|
|
InputStream inputStream = file.getInputStream(); |
|
|
|
|
client.createClient().putObject(tencentConfig.getPhotoBucket(),name,inputStream,null); |
|
|
|
|
String imgUrl = getImgUrl(name); |
|
|
|
|
Map<String, Object> map=new HashMap<>(); |
|
|
|
|
map.put("url", imgUrl); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String uploadImg2Cos(String url) throws Exception { |
|
|
|
|
File fileOnServer = new File(url); |
|
|
|
@ -285,6 +299,7 @@ public class TencentUploadServiceImpl implements TencentUploadService {
|
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getNftUrl(String key) { |
|
|
|
|
// 设置URL过期时间为10年 3600l* 1000*24*365*10
|
|
|
|
|
Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000 * 24 * 365 * 10); |
|
|
|
|