{"record":{"id":"6be26fcf4e856654","repo":"paascloud/paascloud-master","slug":"opc10040009","errorCode":"OPC10040009","errorMessage":"OPC10040009","messagePattern":"OPC10040009","errorType":"error_code","errorClass":"OpcBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptQiniuOssServiceImpl.java","lineNumber":147,"sourceCode":"\t\tlog.info(\"uploadFile - 上传文件. fileName={}, bucketName={}\", fileName, bucketName);\n\n\t\tPreconditions.checkArgument(uploadBytes != null, \"读取文件失败\");\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(fileName), ErrorCodeEnum.OPC10040010.msg());\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(filePath), \"文件路径不能为空\");\n\t\tPreconditions.checkArgument(StringUtils.isNotEmpty(bucketName), \"存储节点不能为空\");\n\n\t\tInputStream is = new ByteArrayInputStream(uploadBytes);\n\t\tString inputStreamFileType = FileTypeUtil.getType(is);\n\t\tString newFileName = UniqueIdGenerator.generateId() + \".\" + inputStreamFileType;\n\n\t\t// 检查数据大小\n\t\tthis.checkFileSize(uploadBytes);\n\n\t\tResponse response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));\n\t\tDefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);\n\t\tlog.info(\"uploadFile - 上传文件. [OK] putRet={}\", putRet);\n\t\tif (PublicUtil.isEmpty(putRet) || StringUtils.isEmpty(putRet.key)) {\n\t\t\tthrow new OpcBizException(ErrorCodeEnum.OPC10040009);\n\t\t}\n\t\tString fileUrl;\n\t\t// 获取图片路径\n\t\tif (StringUtils.equals(OPEN_IMG_BUCKET, bucketName)) {\n\t\t\tfileUrl = paascloudProperties.getQiniu().getOss().getPublicHost() + \"/\" + filePath + newFileName;\n\t\t} else {\n\t\t\tString domainUrl = paascloudProperties.getQiniu().getOss().getPrivateHost();\n\t\t\tfileUrl = this.getFileUrl(domainUrl, fileName);\n\t\t}\n\t\tOptUploadFileRespDto result = new OptUploadFileRespDto();\n\t\tresult.setAttachmentUrl(fileUrl);\n\t\tresult.setAttachmentName(newFileName);\n\t\tresult.setAttachmentPath(filePath);\n\t\treturn result;\n\t}\n\n\tprivate String getUpToken(String bucketName) {\n\t\treturn auth.uploadToken(bucketName);","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/service/impl/OptQiniuOssServiceImpl.java#L129-L165","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nResponse response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));\nDefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);\nif (PublicUtil.isEmpty(putRet) || StringUtils.isEmpty(putRet.key)) {\n    throw new OpcBizException(ErrorCodeEnum.OPC10040009);\n}\n// after\nResponse response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));\nif (!response.isOK()) {\n    log.error(\"qiniu upload failed: {}\", response.bodyString()); // surface real cause\n    throw new OpcBizException(ErrorCodeEnum.OPC10040009);\n}\nDefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);","handlingStrategy":"try-catch","validationCode":"Response response = uploadManager.put(uploadBytes, filePath + newFileName, getUpToken(bucketName));\nif (!response.isOK() || PublicUtil.isEmpty(response.bodyString())) {\n    throw new OpcBizException(ErrorCodeEnum.OPC10040009);\n}","typeGuard":null,"tryCatchPattern":"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\"); } }","preventionTips":["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"],"tags":["qiniu","oss","upload"],"backgroundTag":"http-error-response","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}