Android – how to download images from AWS S3 to ImageView?

Therefore, I want to be able to grab an image from the S3 bucket and load it (using taxiing or Picasso) into ImageView (I don't want to download the image to my phone)

At present, I have this:

 downloadButton = (Button) findViewById(R.id.cognito_s3DownloadButton);
        downloadButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                File file = new File(Environment.getExternalStorageDirectory().toString() + "/" + "fromAWS");
                observer = transferUtility.download("zivit-card-images","image1", file);
                Glide.with(getBaseContext()).load("image in byes? or url?").centerCrop().into(myImageView);
            }
        });

Again, how do I retrieve an image from S3 and insert it into ImageView?

resolvent:

When using glass or Picasso, you don't have to worry about where you want to save the image. Picasso or glide are responsible for caching, so you don't have to

Now, all you need to use glass or Picasso to set the image to ImageView is an image URL. I think you want to use the image in S3 bucket, and then you need the image in S3 bucket, as shown below:

https://a2.muscache.com/im/pictures/9c66dcc5-6d39-43b3-82ec-72e9d119f873.jpg

All you need to do is:

downloadButton = (Button) findViewById(R.id.cognito_s3DownloadButton);
   downloadButton.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
            Glide.with(getBaseContext())
                 .load("https://a2.muscache.com/im/pictures/9c66dcc5-6d39-43b3-82ec-72e9d119f873.jpg")
                 .centerCrop()
                 .into(myImageView);
       }
});

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>