Hello! The problem seems to be standard, but nothing good comes out of the Internet examples. Task: on a mobile application, select a picture from the phone and send restSharp to the server using restSharp. RestSharp asks for the path to the file, but does not find the address that gives Uri "content: //com.android.providers.media.documents/document/image: 18", so probably a straight path is needed. Here's how to get it? From below, I gave a typical example that returns null for me, but Uri itself is correct, since the image is completely inserted into the imageView. Maybe someone solved such a problem of transferring the restSharp file.
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { var imageView = FindViewById<ImageView>(Resource.Id.editAvatarImageView); imageView.SetImageURI(data.Data); selectedAvatar = data.Data; string path = null; string[] projection = new[] { Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data }; using (ICursor cursor = ContentResolver.Query(data.Data, projection, null, null, null)) { if (cursor != null) { int columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data); cursor.MoveToFirst(); path = cursor.GetString(columnIndex); } } } }
getContentResolver().openInputStream(uri)is available? - Eugene Krivenja