paascloud/paascloud-master · error · OpcBizException
OPC10040009
OPC10040009
Error message
OPC10040009
What it means
OpcBizException with code OPC10040009 thrown by OptQiniuOssServiceImpl.uploadFile after a Qiniu upload when the parsed DefaultPutRet is empty or its key is blank. The qiniu uploadManager.put call returned a body that did not yield a usable key, indicating the upload did not actually succeed as expected (e.g. the response was an error body).
Solutions
- Check the logs for putRet and response.bodyString() to see the raw Qiniu error and act on it
- Verify qiniu oss accessKey/secretKey/bucket configuration and that the upToken is generated for the correct bucket and zone
- Confirm the bucket exists in the right region and credentials have upload permission and quota
- Re-run the upload after fixing config; check file size against checkFileSize limits
Example fix
// before
Response response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
if (PublicUtil.isEmpty(putRet) || StringUtils.isEmpty(putRet.key)) {
throw new OpcBizException(ErrorCodeEnum.OPC10040009);
}
// after
Response response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));
if (!response.isOK()) {
log.error("qiniu upload failed: {}", response.bodyString()); // surface real cause
throw new OpcBizException(ErrorCodeEnum.OPC10040009);
}
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); Defensive patterns
Strategy: try-catch
Validate before calling
Response response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));
if (!response.isOK() || PublicUtil.isEmpty(response.bodyString())) {
throw new OpcBizException(ErrorCodeEnum.OPC10040009);
} Try / catch
try { uploadFile(bytes, name, type, path, bucket, auth); } catch (OpcBizException e) { if ("OPC10040009".equals(e.getCode())) { log.error("qiniu upload failed, check credentials/bucket/zone"); } } Prevention
- Validate Qiniu accessKey/secretKey/bucket/zone configuration at startup
- Check response.isOK() and log bodyString() before parsing DefaultPutRet
- Sync server clocks so upTokens do not expire prematurely
- Monitor quotas and file-size limits upstream of upload
- Retry transient network failures with backoff before surfacing OPC10040009
When it happens
Trigger: Qiniu upload response body is an error JSON (invalid accessKey/secretKey, wrong bucket, expired upToken, quota exceeded) so deserialized DefaultPutRet has no key; empty response body from the storage endpoint; network/proxy returning a non-JSON body.
Common situations: Misconfigured qiniu.oss credentials or bucket name in paascloud properties; expired token when system clock is skewed; wrong region/zone endpoint for the bucket; file size or quota rejections; response body logging shows the real Qiniu error.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/6be26fcf4e856654.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptQiniuOssServiceImpl.java:147
log.info("uploadFile - 上传文件. fileName={}, bucketName={}", fileName, bucketName);
Preconditions.checkArgument(uploadBytes != null, "读取文件失败");
Preconditions.checkArgument(StringUtils.isNotEmpty(fileName), ErrorCodeEnum.OPC10040010.msg());
Preconditions.checkArgument(StringUtils.isNotEmpty(filePath), "文件路径不能为空");
Preconditions.checkArgument(StringUtils.isNotEmpty(bucketName), "存储节点不能为空");
InputStream is = new ByteArrayInputStream(uploadBytes);
String inputStreamFileType = FileTypeUtil.getType(is);
String newFileName = UniqueIdGenerator.generateId() + "." + inputStreamFileType;
// 检查数据大小
this.checkFileSize(uploadBytes);
Response response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
log.info("uploadFile - 上传文件. [OK] putRet={}", putRet);
if (PublicUtil.isEmpty(putRet) || StringUtils.isEmpty(putRet.key)) {
throw new OpcBizException(ErrorCodeEnum.OPC10040009);
}
String fileUrl;
// 获取图片路径
if (StringUtils.equals(OPEN_IMG_BUCKET, bucketName)) {
fileUrl = paascloudProperties.getQiniu().getOss().getPublicHost() + "/" + filePath + newFileName;
} else {
String domainUrl = paascloudProperties.getQiniu().getOss().getPrivateHost();
fileUrl = this.getFileUrl(domainUrl, fileName);
}
OptUploadFileRespDto result = new OptUploadFileRespDto();
result.setAttachmentUrl(fileUrl);
result.setAttachmentName(newFileName);
result.setAttachmentPath(filePath);
return result;
}
private String getUpToken(String bucketName) {
return auth.uploadToken(bucketName);View on GitHub (pinned to 781281a950)