|
@@ -122,22 +122,6 @@ public class AliOSSUtils {
|
122
|
122
|
}
|
123
|
123
|
} while (result.isTruncated());
|
124
|
124
|
return size;
|
125
|
|
- try {
|
126
|
|
- InputStream inputStream = file.getInputStream();
|
127
|
|
- // 避免文件覆盖
|
128
|
|
- String originalFilename = file.getOriginalFilename();
|
129
|
|
- String fileName = "file/" + LocalDate.now() + "/" + UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
|
130
|
|
- //上传文件到 OSS
|
131
|
|
- OSS ossClient = new OSSClientBuilder().build(aliProperties.getEndpoint(), aliProperties.getAccessKeyId(), aliProperties.getAccessKeySecret());
|
132
|
|
- threadPoolUtil.getTaskExecutor().execute(() -> {
|
133
|
|
- ossClient.putObject(aliProperties.getBucketName(), fileName, inputStream);
|
134
|
|
- ossClient.shutdown();
|
135
|
|
- });
|
136
|
|
- //文件访问路径
|
137
|
|
- return aliProperties.getOsspath().split("//")[0] + "//" + aliProperties.getBucketName() + "." + aliProperties.getOsspath().split("//")[1] + "/" + fileName;
|
138
|
|
- } catch (IOException e) {
|
139
|
|
- throw new RuntimeException(e);
|
140
|
|
- }
|
141
|
125
|
}
|
142
|
126
|
|
143
|
127
|
public void deleteModel(String path) {
|