Luis Daivid
12/31/2022, 1:13 PMrememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
if (uri != null) {
// I want uri to file
uri.toFile() // error
}
}
I got the content uri of the image from the code above.
I want to send this image file to the server using retrofit, how do I do that?
When I used uri.toFIle() to use the code below, I got an error.
fun File.toImageMultipartBody(key: String): MultipartBody.Part =
MultipartBody.Part.createFormData(
name = key,
filename = name,
body = asRequestBody("image/*".toMediaType())
)
error : Uri lacks 'file' scheme: <content://media/external/images/media/9>
Chrimaeon
12/31/2022, 1:42 PMChrimaeon
12/31/2022, 1:46 PMMark Murphy
12/31/2022, 4:52 PMLuis Daivid
01/02/2023, 12:42 PMChrimaeon
01/02/2023, 12:43 PMLuis Daivid
01/02/2023, 12:44 PM