Android 10 打开失败:PDF 的 ENOENT(没有这样的文件或目录)

时间:2020-12-22 08:42:10

标签: android retrofit2 multipart android-10.0 filepicker

我遇到了 pdf 的问题,我想使用 Multipart 上传 pdf,但问题是当我传递文件路径时,android 10 给了我这个错误。

打开失败:ENOENT(没有那个文件或目录)

Android 10 上的文件路径:-

/document/home:578563_Aarohi_Tushar_Bodke_FeeReceipt_ExportToPDF.pdf:打开失败:ENOENT(没有那个文件或目录)

代码:-

        File file = new File(myUri.getPath());
        System.out.println("file-->" + file.getName());


        System.out.println("Upload_ANY_PDF_File--> " + file.getName());

        RequestBody requestBodyimage = RequestBody.create(MediaType.parse("application/" + "pdf"), file);
        MultipartBody.Part imagefileToUpload = MultipartBody.Part.createFormData("url", file.getName(), requestBodyimage);

1 个答案:

答案 0 :(得分:0)

记录文件路径并确保您的路径正确