Merge https://git.pig4cloud.com/24889356/pigx into leng_dev
This commit is contained in:
commit
bfe8cc2336
2 files changed
+12
-6
No files matched your search
+8
-2
@@ -22,11 +22,13 @@ import com.amazonaws.services.s3.model.S3Object;
|
||||
import com.amazonaws.services.s3.model.S3ObjectSummary;
|
||||
import com.pig4cloud.pigx.common.oss.service.OssTemplate;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Cleanup;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -84,7 +86,9 @@ public class OssEndpoint {
|
||||
@PostMapping("/object/{bucketName}")
|
||||
public S3Object createObject(@RequestBody MultipartFile object, @PathVariable String bucketName) {
|
||||
String name = object.getOriginalFilename();
|
||||
template.putObject(bucketName, name, object.getInputStream(), object.getSize(), object.getContentType());
|
||||
@Cleanup
|
||||
InputStream inputStream = object.getInputStream();
|
||||
template.putObject(bucketName, name, inputStream, object.getSize(), object.getContentType());
|
||||
return template.getObjectInfo(bucketName, name);
|
||||
|
||||
}
|
||||
@@ -93,7 +97,9 @@ public class OssEndpoint {
|
||||
@PostMapping("/object/{bucketName}/{objectName}")
|
||||
public S3Object createObject(@RequestBody MultipartFile object, @PathVariable String bucketName,
|
||||
@PathVariable String objectName) {
|
||||
template.putObject(bucketName, objectName, object.getInputStream(), object.getSize(), object.getContentType());
|
||||
@Cleanup
|
||||
InputStream inputStream = object.getInputStream();
|
||||
template.putObject(bucketName, objectName, inputStream, object.getSize(), object.getContentType());
|
||||
return template.getObjectInfo(bucketName, objectName);
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -67,13 +68,12 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
resultMap.put("fileName", fileName);
|
||||
resultMap.put("url", String.format("/admin/sys-file/%s/%s", ossProperties.getBucketName(), fileName));
|
||||
|
||||
try {
|
||||
minioTemplate.putObject(ossProperties.getBucketName(), fileName, file.getInputStream(),
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
minioTemplate.putObject(ossProperties.getBucketName(), fileName, inputStream,
|
||||
file.getContentType());
|
||||
// 文件管理数据记录,收集管理追踪文件
|
||||
fileLog(file, fileName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("上传失败", e);
|
||||
return R.failed(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user