如何将图像从AWS S3下载到ImageView? [英] How to download image from aws s3 into imageview?

查看:303
本文介绍了如何将图像从AWS S3下载到ImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我希望能够从s3存储桶中抓取图像并将图像(使用滑行或毕加索)加载到imageview中. (我不想将该图像下载到手机中.)

so I want to be able to grab my images from my s3 bucket and (using glide or picasso) load that image into an imageview. (I don't want to download that image into my phone).

目前我有这个:

 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);
            }
        });

再次,我该如何从s3中检索图像并将其插入到imageview中?

Again, how do i retrieve the image from s3 and insert it into an imageview?

推荐答案

使用Glide或Picasso时,您不必担心image的保存位置.毕加索或Glide负责Caching的使用,因此您不必这样做.

When using Glide or Picasso, you need not worry about the location where the image will be saved. Picasso or Glide takes care of the Caching so that you don't have to.

现在,使用Glide或Picasso将图像设置为ImageView所需要做的就是图像URL.我想您想使用S3存储桶中的图像,然后需要S3存储桶中的图像,如下所示:

Now, all you need to set an Image to an ImageView using Glide or Picasso is an image URL. I think you want to use an image from your S3 bucket, then you need to have an image from your S3 bucket, something like this:

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

那么您要做的就是:

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);
       }
});

这篇关于如何将图像从AWS S3下载到ImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆