jeecgboot/JeecgBoot · error · JeecgBootException
上传文件失败!
Error message
上传文件失败!
What it means
Thrown by OssFileServiceImpl.upload when OssBootUtil.upload returns null/empty for the given MultipartFile. The upload helper returns empty on any internal failure (missing OSS config, SDK exception, IO error), and this wrapper converts that silent failure into an explicit JeecgBootException so the caller sees the upload did not succeed.
Source
Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/oss/service/impl/OssFileServiceImpl.java:31
import java.io.IOException;
/**
* @Description: OSS云存储实现类
* @author: jeecg-boot
*/
@Service("ossFileService")
public class OssFileServiceImpl extends ServiceImpl<OssFileMapper, OssFile> implements IOssFileService {
@Override
public void upload(MultipartFile multipartFile) throws Exception {
String fileName = multipartFile.getOriginalFilename();
fileName = CommonUtils.getFileName(fileName);
OssFile ossFile = new OssFile();
ossFile.setFileName(fileName);
String url = OssBootUtil.upload(multipartFile,"upload/test");
if(oConvertUtils.isEmpty(url)){
throw new JeecgBootException("上传文件失败! ");
}
// 返回阿里云原生域名前缀URL
ossFile.setUrl(OssBootUtil.getOriginalUrl(url));
this.save(ossFile);
}
@Override
public boolean delete(OssFile ossFile) {
try {
this.removeById(ossFile.getId());
OssBootUtil.deleteUrl(ossFile.getUrl());
}
catch (Exception ex) {
log.error(ex.getMessage(),ex);
return false;
}
return true;
}View on GitHub (pinned to 96fb33f5ec)
Solutions
- Verify the jeecg.uploadType and the corresponding jeecg.oss / minio / aliyun / qiniu config block in application.yml are complete and correct.
- Check network reachability and credentials for the storage endpoint (bucket exists, key has write permission).
- Inspect the OssBootUtil logs (it logs the underlying SDK exception before returning null) for the real cause.
- Confirm the MultipartFile is non-empty and its stream is readable.
Example fix
// before: jeecg.uploadType: minio but no minio endpoint configured -> upload() returns null
// after: jeecg:
// uploadType: minio
// minio:
// endpoint: http://minio:9000
// accessKey: ${MINIO_AK}
// secretKey: ${MINIO_SK}
// bucketName: jeecg Defensive patterns
Strategy: try-catch
Validate before calling
// Verify OSS config completeness at startup
boolean configured = StringUtils.hasText(env.getProperty("jeecg.uploadType"))
&& ("local".equals(env.getProperty("jeecg.uploadType"))
|| StringUtils.hasText(env.getProperty("jeecg.oss.endpoint"))
|| StringUtils.hasText(env.getProperty("jeecg.minio.endpoint")));
if (!configured) { /* fail fast / warn at boot */ } Try / catch
try {
ossFileService.upload(file);
} catch (JeecgBootException e) {
if (e.getMessage().contains("上传文件失败")) {
// log OssBootUtil root cause; do not retry until config/network fixed
}
} Prevention
- Set jeecg.uploadType and the matching provider config block before going live.
- Health-check the storage endpoint and credentials in the readiness probe.
- Surface OssBootUtil's underlying exception in logs so the silent null is debuggable.
When it happens
Trigger: OSS provider credentials/endpoint/bucket not configured (jeecg.oss.* properties); MinIO/OSS endpoint unreachable; bucket does not exist; file stream closed/empty; the configured jeecg.uploadType does not match an available provider.
Common situations: Fresh deployment that forgot to set OSS credentials; network/firewall blocking the storage endpoint; expired STS token; switched jeecg.uploadType (local/minio/aliyun/qiniu) without providing the matching config.
Related errors
- 上传业务路径深度超出限制!
- 类 {ruleClass} 未实现 IFillRuleHandler 接口
- 数据源URL配置格式不正确!
- 动态数据源连接失败,dbKey:{dbKey}
- DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/d5c61ae4fc2ed727.
Report an issue: GitHub.