I am trying to load an image from the server with cookies
If the cookies are correct, then correct image is displayed but if the Cookies are incorrect then a placeholder image is received.
I am using following code to display image
val request =
ImageRequest.Builder(this)
.placeholder(R.drawable.tier_4_excel_2)
.addHeader("Cookie", "MoodleSession=741ait3989s5d24bvhi1j8fdpk")
.addHeader("MoodleSession", "741ait3989s5d24bvhi1j8fdpk")
.setHeader("Cookie", "MoodleSession=741ait3989s5d24bvhi1j8fdpk")
.setHeader("MoodleSession", "741ait3989s5d24bvhi1j8fdpk")
.data("https://uat.XXXX.com/pluginfile.php/217833/user/icon/backstage2/f1")
.transformations(CircleCropTransformation())
.target(onSuccess = { result ->
mToolbarImage.setImageDrawable(result)
}, onError = { error ->
println("IMAGE LOAD ERROR >>>>>> $error")
// Handle the error drawable.
}).build()
imageLoader.enqueue(request)
Code is constantly navigating to onSuccess with a placeholder image, which means Cookies are incorrect.
Postman screenshot when an image is correctly displayed with Cookies
Any help in this is appreciated
I was implementing coil version 3 for compose recently and I found this.
please check if the image type is supported by the coil version you are using check this link
As well as adding the extension in the data may help:
.data("https://uat.XXXX.com/pluginfile.php/217833/user/icon/backstage2/f1.jpg")
Hope this is helpful for you!