!313 修复上传七牛云无mime type问题

This commit is contained in:
YunaiV
2022-11-29 22:16:10 +08:00
parent 583cb9388a
commit 5f8c569a70
13 changed files with 17 additions and 17 deletions

View File

@@ -31,8 +31,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.util.Collection;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -193,7 +193,7 @@ public class FileConfigServiceImpl implements FileConfigService {
// 校验存在
FileConfigDO config = this.validateFileConfigExists(id);
if (Boolean.TRUE.equals(config.getMaster())) {
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
}
// 删除
fileConfigMapper.deleteById(id);
@@ -230,7 +230,7 @@ public class FileConfigServiceImpl implements FileConfigService {
this.validateFileConfigExists(id);
// 上传文件
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg");
return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg", "image/jpeg");
}
@Override

View File

@@ -52,7 +52,7 @@ public class FileServiceImpl implements FileService {
// 上传到文件存储器
FileClient client = fileConfigService.getMasterFileClient();
Assert.notNull(client, "客户端(master) 不能为空");
String url = client.upload(content, path);
String url = client.upload(content, path, type);
// 保存到数据库
FileDO file = new FileDO();