old monkey 2021-08-06 18:45
浏览 78
已结题

项目中使用华为OBS进行图片上传,出现BUG

在SpringMVC项目的controller层中编写接口pictureUpload(@RequestParam("file") MultipartFile srcFile)

    public WxResultEntity pictureUpload(@RequestParam("file") MultipartFile srcFile){
        String fileName = srcFile.getOriginalFilename();
        StringBuffer buffer = new StringBuffer("imageCloud/");
        buffer.append(fileName);
        String upLoadName = buffer.toString();
        WxResultEntity wre = new WxResultEntity();

        if(srcFile.isEmpty()){
           return null;
        }

        try{
            byte[] bytes = srcFile.getBytes();
            boolean flag = OBSFileUtils.uploadForBytes(bytes,upLoadName);
            if(flag) {
                wre.setStatus(200);
                wre.setResultInfo(upLoadName;
            }
            return wre;
        }catch (Exception e){
            e.printStackTrace();
            return wre;
        }

    }

调用接口后flag为false并且抛出如下异常

com.obs.services.exception.ObsException: OBS servcie Error Message. Request Error: java.lang.NoSuchMethodError: okhttp3.internal.http.RealInterceptorChain.transmitter()Lokhttp3/internal/connection/Transmitter;

Caused by: java.lang.NoSuchMethodError: okhttp3.internal.http.RealInterceptorChain.transmitter()Lokhttp3/internal/connection/Transmitter;

排查为com\obs\services\internal\service\AbstractRequestConvertor.class 类中以下代码块

if (apiVersion == null) {
                try {
                    this.segmentLock.lock(bucketName);
                    apiVersion = this.apiVersionCache.getApiVersionInCache(bucketName);
                    if (apiVersion == null) {
                        apiVersion = this.parseAuthTypeInResponse(bucketName);
                        this.apiVersionCache.addApiVersion(bucketName, apiVersion);
                    }
                } 

apiVersion = this.parseAuthTypeInResponse(bucketName);

this.apiVersionCache.addApiVersion(bucketName, apiVersion);

出现问题使得apiVersion出现赋值错误。

okhttp-4.9.0.jar
jdk版本为1.8

有知道的朋友看到的话能不能回复一下解决方案啊

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月14日
    • 创建了问题 8月6日

    悬赏问题

    • ¥50 rk3588板端推理
    • ¥50 opencv怎么去掉 数字0中间的斜杠。
    • ¥15 这种情况的伯德图和奈奎斯特曲线怎么分析?
    • ¥50 paddleocr带斜线的0很容易识别成9
    • ¥15 电子档案元素采集(tiff及PDF扫描图片)
    • ¥15 flink-sql-connector-rabbitmq使用
    • ¥15 zynq7015,PCIE读写延时偏大
    • ¥15 使用spss做psm(倾向性评分匹配)遇到问题
    • ¥20 vue+UEditor附件上传问题
    • ¥15 想做个WPS的自动化代码,不知道能做的起不。