okhttp上传图片open failed: ENOENT (No such file or directory)

这两天使用okhttp框架上传图片,发生了一个问题open failed: ENOENT,说文件打不开,明明图片路径都是对的,怎么就打不开呢? 

Environment.getExternalStorageDirectory() +  File.separator + Contants.IMAGE_FILE_AVATARNAME_PATH

备注:sd卡路径 + ‘/’ + “attendance/Camera/”

原来是图片路径文件夹超不过了一层(Contants.IMAGE_FILE_AVATARNAME_PATH =”attendance/Camera/”)

okhttp中对打开多级路径的图片不支持(没写好,有时用第三方的东西真心累),然后把存的图片路径改成一层:Contants.IMAGE_FILE_AVATARNAME_PATH =”attendance/”

然后就ok了

    原文作者:onlyxing
    原文地址: https://www.jianshu.com/p/79d913ae17ac
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞