```rememberLauncherForActivityResult(ActivityResul...
# android
l
Copy code
rememberLauncherForActivityResult(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.
Copy code
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>
c
Luis, this a Kotlin related workspace. For your general android question, please see the channel description for more appropriate places to ask.
Hint for your issue: content resolver
❤️ 1
l
@Chrimaeon here is android channel. isn’t it?
c
yes, but android question with a Kotlin background. not general Android questions. see https://kotlinlang.org/community/slackccugl.html#common-channels
l
Oh. I see. Thanks