Glide - adding header to request

前端 未结 8 1442
北海茫月
北海茫月 2021-02-02 09:25

is there a method to add custom header to request when image is downloaded? I can use volley or okhttp in Glide.

I try add cookie to cookiemanager in okhttpclient, but i

8条回答
  •  忘了有多久
    2021-02-02 09:50

    Kotlin + Glide 4.10.0

    val token = "..."
    val url = https://url.to.your.image
    val glideUrl = GlideUrl(url) { mapOf(Pair("Authorization", "Bearer $token")) }
    
    Glide.with(context)
         .load(glideUrl)
         .into(imageView)
    

提交回复
热议问题