Skip to content

Commit

Permalink
🐛 上传文件后关闭流,防止too many open files异常
Browse files Browse the repository at this point in the history
  • Loading branch information
springboot4 committed Apr 12, 2022
1 parent 33d3f6f commit 95ef0e9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/pig4cloud/plugin/oss/http/OssEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public S3ObjectSummary createObject(@RequestBody @NotNull MultipartFile object,
InputStream inputStream = object.getInputStream();
String name = object.getOriginalFilename();

ossTemplate.putObject(bucketName, name,inputStream, object.getSize(), object.getContentType());
ossTemplate.putObject(bucketName, name, inputStream, object.getSize(), object.getContentType());
S3Object objectInfo = ossTemplate.getObjectInfo(bucketName, name);
ObjectMetadata objectMetadata = objectInfo.getObjectMetadata();
S3ObjectSummary objectSummary = new S3ObjectSummary();
Expand All @@ -120,8 +120,7 @@ public S3ObjectSummary createObject(@RequestBody @NotNull MultipartFile object,
@PathVariable @NotBlank String bucketName, @PathVariable @NotBlank String objectName) {
@Cleanup
InputStream inputStream = object.getInputStream();
ossTemplate.putObject(bucketName, objectName,inputStream , object.getSize(),
object.getContentType());
ossTemplate.putObject(bucketName, objectName, inputStream, object.getSize(), object.getContentType());
S3Object objectInfo = ossTemplate.getObjectInfo(bucketName, objectName);
ObjectMetadata objectMetadata = objectInfo.getObjectMetadata();
S3ObjectSummary objectSummary = new S3ObjectSummary();
Expand Down

0 comments on commit 95ef0e9

Please sign in to comment.