Pre Merge pull request !211 from 刘亚洲/4.X

This commit is contained in:
刘亚洲 2022-07-26 06:15:11 +00:00 committed by Gitee
commit bf033241ef
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -97,6 +97,11 @@ public class OssClient {
client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata));
} catch (Exception e) {
throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]");
}finally {
//如果是阿里云时必须关闭数据量大时否则会出现oom的情况
if (client != null) {
client.shutdown();
}
}
return UploadResult.builder().url(getUrl() + "/" + path).filename(path).build();
}
@ -107,6 +112,10 @@ public class OssClient {
client.deleteObject(properties.getBucketName(), path);
} catch (Exception e) {
throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]");
}finally {
if (client != null) {
client.shutdown();
}
}
}