0

I'm loading images from external URLs with Picasso. To prevent someone from hosting huge files that would hang my app I would like to set a max image file size before downloading it.

Is there a way in Picasso to limit the file size? If no, what's an alternative?

A1m
  • 2,897
  • 2
  • 24
  • 39

1 Answers1

1

You'll have to provide your own OkHttpClient to Picasso (via its Builder) to handle that. Generally speaking you'll need to issue a request to the server to figure out the size of the image and only then decide if you want to get it or not. Check this answer for more details.

takecare
  • 1,684
  • 3
  • 21
  • 32
  • I was aware of this thread but wasn't aware I can supply an Okhttp instance. Found that it requires an implementation of `Downloader`. I will try this route, thanks :) – A1m Feb 13 '21 at 06:19