Skip to content Skip to sidebar Skip to footer

Get Redirected Url From Picasso

I'm fetching my images using the following code: Picasso.with(mContext) .load(myImage.getUrl()) .fetch(); myImage.getUrl() returns a URL from

Solution 1:

OkHttp allows you not to follow redirects automatically:

OkHttpClientclient=newOkHttpClient();
client.setFollowRedirects(false);

You can read the response, get the redirect URL and then forward it manually to Picasso.

EDIT:

Interceptors are feasible as well:

OkHttpClientclient=newOkHttpClient();
client.interceptors().add(newInterceptor() {
  @Overridepublic Response intercept(Chain chain)throws IOException {
    // process response herereturn response;
  }
});

Solution 2:

I fixed it by this code.

valdownloader= OkHttp3Downloader(context)
Picasso.Builder(context).downloader(downloader).build()

Check this for detail. https://github.com/square/picasso/issues/463

Solution 3:

Add okhttp dependency

compile'com.squareup.okhttp:okhttp:2.5.0'

and try this code

  Picasso.Builder builder =new Picasso.Builder(context);
  builder.downloader(new OkHttpDownloader(context));
  builder.build()
 .load(path.trim())
 .into(imageView);

This code working for me

Post a Comment for "Get Redirected Url From Picasso"