打开失败:在kotlin中ENOENT(没有这样的文件或目录)

我试图从gallery获取图像并将其发送给retrofit 。 发送我面临异常的图像。

E /错误:文件:/storage/sdcard0/Pictures/JPEG_20171012125800_1088307192.jpg:打开失败:ENOENT(没有这样的文件或目录)

以下是我的代码的显示。 这是kotlin。 点击按钮事件:

  img_add.setOnClickListener { var count = layout_direct_cemara.childCount isPermissionRequestRequired(this, perms, 1) if (count < 5) { setMultiShowButton() } else { C.showToast(applicationContext , "You can upload maximum 5 images") } } 

以下是两个函数获取图像并将其设置为我的布局。

  private fun setMultiShowButton() { val bottomSheetDialogFragment = TedBottomPicker.Builder(this) .setOnMultiImageSelectedListener { uriList -> selectedUriList = uriList showUriList(uriList) } .setPeekHeight(1600) .showTitle(false) .setCompleteButtonText("Done") .setEmptySelectionText("No Select") .setSelectedUriList(selectedUriList) .create() bottomSheetDialogFragment.show(supportFragmentManager) } private fun showUriList(uriList: java.util.ArrayList<Uri>) { // Remove all views before // adding the new ones. layout_direct_cemara.removeAllViews() layout_direct_cemara.setVisibility(View.VISIBLE) val wdpx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100f, resources.displayMetrics).toInt() val htpx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100f, resources.displayMetrics).toInt() if (uriList.size <= 5) { for (uri in uriList) { Log.e("uri", "" + uri.toString()) val imageHolder = LayoutInflater.from(this).inflate(R.layout.layout_post_add_photo_item, null) val thumbnail = imageHolder.findViewById<ImageView>(R.id.img_photo) as ImageView Glide.with(this) .load(uri.toString()) .fitCenter() .into(thumbnail) layout_direct_cemara.addView(imageHolder) thumbnail.layoutParams = FrameLayout.LayoutParams(wdpx, htpx) } } else { Toast.makeText(this, "Please Select Maximum 5 Images Only", Toast.LENGTH_SHORT).show() } } 

这是我如何发送图像进行改造。

  var selectedImages: ArrayList<MultipartBody.Part>?=ArrayList<MultipartBody.Part>() val count = layout_direct_cemara.childCount for (i in 0 until count) { var fileBody: MultipartBody.Part? = prepareFilePart("image_" + (i + 1), selectedUriList.get(i).toString()) selectedImages?.add(fileBody!!) Log.e("letsCheck", "--->" + selectedUriList.get(i).toString()) } dialog?.show() val postMyAdd = adminAPI?.PostAdvertise(selectedImages) 

请帮我解决这个错误。