fix 修复 使用缓冲流 导致上传异常问题 回滚错误提交 #35fac6c
This commit is contained in:
parent
ee80e97578
commit
afac00de33
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.oss.core;
|
package com.ruoyi.oss.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.amazonaws.ClientConfiguration;
|
import com.amazonaws.ClientConfiguration;
|
||||||
import com.amazonaws.HttpMethod;
|
import com.amazonaws.HttpMethod;
|
||||||
@ -97,6 +98,9 @@ public class OssClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UploadResult upload(InputStream inputStream, String path, String contentType) {
|
public UploadResult upload(InputStream inputStream, String path, String contentType) {
|
||||||
|
if (!(inputStream instanceof ByteArrayInputStream)) {
|
||||||
|
inputStream = new ByteArrayInputStream(IoUtil.readBytes(inputStream));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ObjectMetadata metadata = new ObjectMetadata();
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
metadata.setContentType(contentType);
|
metadata.setContentType(contentType);
|
||||||
|
@ -114,7 +114,7 @@ public class SysOssServiceImpl implements ISysOssService {
|
|||||||
OssClient storage = OssFactory.instance();
|
OssClient storage = OssFactory.instance();
|
||||||
UploadResult uploadResult;
|
UploadResult uploadResult;
|
||||||
try {
|
try {
|
||||||
uploadResult = storage.uploadSuffix(file.getInputStream(), suffix, file.getContentType());
|
uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user