update 优化 oss上传直接从请求头获取文件类型

dev
疯狂的狮子Li 1 year ago
parent a35b32ef4d
commit 05ad9bc907

@ -340,8 +340,8 @@ public class OssClient {
* @return UploadResult * @return UploadResult
* @throws OssException * @throws OssException
*/ */
public UploadResult uploadSuffix(byte[] data, String suffix) { public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) {
return upload(new ByteArrayInputStream(data), getPath(properties.getPrefix(), suffix), Long.valueOf(data.length), FileUtils.getMimeType(suffix)); return upload(new ByteArrayInputStream(data), getPath(properties.getPrefix(), suffix), Long.valueOf(data.length), contentType);
} }
/** /**
@ -353,8 +353,8 @@ public class OssClient {
* @return UploadResult * @return UploadResult
* @throws OssException * @throws OssException
*/ */
public UploadResult uploadSuffix(InputStream inputStream, String suffix, Long length) { public UploadResult uploadSuffix(InputStream inputStream, String suffix, Long length, String contentType) {
return upload(inputStream, getPath(properties.getPrefix(), suffix), length, FileUtils.getMimeType(suffix)); return upload(inputStream, getPath(properties.getPrefix(), suffix), length, contentType);
} }
/** /**

@ -173,7 +173,7 @@ public class SysOssServiceImpl implements ISysOssService {
OssClient storage = OssFactory.instance(); OssClient storage = OssFactory.instance();
UploadResult uploadResult; UploadResult uploadResult;
try { try {
uploadResult = storage.uploadSuffix(file.getBytes(), suffix); 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…
Cancel
Save