I am storing my images on Amazon S3. I use the following code to download image from Amazon S3
S3ObjectInputStream content = s3Client.getObject("bucketname", url).getObjectContent();
byte[] bytes ;
bytes = IOUtils.toByteArray(content);
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
bitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
bitmap = CommonUtilities.getRoundedCornerBitmap(bitmap, 30);
cache.put(url, new SoftReference<Bitmap>(bitmap));
return bitmap;
While going through Picasso documentation, I read that to load images we simply need to do
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
So how to download Amazon S3 images through Picasso.
You are getting the
InputStreamof theS3Object, which will give bytes representation of that object. Instead, you need to build URI from to theS3Object. As far as I know the url is build in following manner:S3_END_POINT + bucket + key.Check the use of
S3Objectredirect location (S3 gives different endpoint url, depending on your location)Therefore: