mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	update 优化 oss上传直接从请求头获取文件类型
This commit is contained in:
		@@ -340,8 +340,8 @@ public class OssClient {
 | 
			
		||||
     * @return UploadResult 包含上传后的文件信息
 | 
			
		||||
     * @throws OssException 如果上传失败,抛出自定义异常
 | 
			
		||||
     */
 | 
			
		||||
    public UploadResult uploadSuffix(byte[] data, String suffix) {
 | 
			
		||||
        return upload(new ByteArrayInputStream(data), getPath(properties.getPrefix(), suffix), Long.valueOf(data.length), FileUtils.getMimeType(suffix));
 | 
			
		||||
    public UploadResult uploadSuffix(byte[] data, String suffix, String contentType) {
 | 
			
		||||
        return upload(new ByteArrayInputStream(data), getPath(properties.getPrefix(), suffix), Long.valueOf(data.length), contentType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -353,8 +353,8 @@ public class OssClient {
 | 
			
		||||
     * @return UploadResult 包含上传后的文件信息
 | 
			
		||||
     * @throws OssException 如果上传失败,抛出自定义异常
 | 
			
		||||
     */
 | 
			
		||||
    public UploadResult uploadSuffix(InputStream inputStream, String suffix, Long length) {
 | 
			
		||||
        return upload(inputStream, getPath(properties.getPrefix(), suffix), length, FileUtils.getMimeType(suffix));
 | 
			
		||||
    public UploadResult uploadSuffix(InputStream inputStream, String suffix, Long length, String contentType) {
 | 
			
		||||
        return upload(inputStream, getPath(properties.getPrefix(), suffix), length, contentType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -195,7 +195,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
 | 
			
		||||
        OssClient storage = OssFactory.instance();
 | 
			
		||||
        UploadResult uploadResult;
 | 
			
		||||
        try {
 | 
			
		||||
            uploadResult = storage.uploadSuffix(file.getBytes(), suffix);
 | 
			
		||||
            uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            throw new ServiceException(e.getMessage());
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user