1 year ago
#75443

WP7
Can I directly load bytes of a jpg file from URL into Glide?
One of our APIs returns bytes of a jpg file.
As I see, there are Network Libraries to download bytes, But I just want to use Glide to download and display.
https://subdomain.example.com:81/stack/146237.jpg
Response Headers type
Content-Length : 209067 Content-Type : image/jpg
A Postman Screenshot of APIs responses
val glideUrl = GlideUrl(
"${BuildConfig.BASE_URL}/stack/146237.jpg",
LazyHeaders.Builder()
.addHeader("Auth", token)
.build()
)
Glide.with(itemView.context)
.asBitmap()
.load(glideUrl)
// .into(object : SimpleTarget<Bitmap?>() {
// override fun onResourceReady(
// resource: Bitmap,
// transition: Transition<in Bitmap?>?
// ) {
// itemView.ivContactHRProfile.setImageBitmap(resource)
// }
// })
.into(object: CustomTarget<Bitmap>(){
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
itemView.ivContactHRProfile.setImageBitmap(resource)
}
override fun onLoadCleared(placeholder: Drawable?) {
}
})
The problem is that I don't know how to implement it with Glide.
android
kotlin
bitmap
byte
android-glide
0 Answers
Your Answer