2

I easily download regular images with jsoup in my android app using these simple lines of code :

            Element image = document.select("img").get(9);

            // Locate the src attribute
            imgSrc = image.absUrl("src");

            Log.d(TAG, "doInBackground: " + imgSrc);

            // Download image from URL
            InputStream input = new java.net.URL(imgSrc).openStream();

            // Decode Bitmap
            bitmap = BitmapFactory.decodeStream(input);

but this time around am trying to download an image whose url looks like this :

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgBLAGQAwEiAAIRAQMRAf/...

and immediately jsoup is having challenges decoding it.

I was wondering how i would download an image like this using jsoup. Any ideas would be appreciated.

itwabi
  • 125
  • 10
  • 1
    There is nothing to download. You already have the image. You need to [decode the Base64-encoded image](https://stackoverflow.com/questions/11106781/decoding-base64-images). – CommonsWare May 01 '20 at 11:05

0 Answers0