如何通过具有私人访问权限的Picasso从AWS加载图像 [英] How to load image from aws with picasso with private access

查看:63
本文介绍了如何通过具有私人访问权限的Picasso从AWS加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Picasso将AWS S3上存储的图像加载到我的android应用程序中,但是我得到的空白图像中我的logcat中没有错误,并且在相关代码行的常规调试中没有任何帮助. 我们对图片具有私人访问权限,因此图片url在浏览器上无法使用. 我需要使用Picasso将图像显示到我的android应用中.但这不起作用.

I'm trying to load image stored on aws S3 into my android app using Picasso but I am getting a blank image with no errors in my logcat and nothing to me from general debugging around the relevant lines of code. We are having private access on images so image url can't work on browser. i need to display image into my android app using Picasso. but it doesn't work.

下面的我的代码段

  new Picasso.Builder(getApplicationContext()).downloader(new S3Downloader(getApplicationContext(), s3Client, bucket))
                .build()
                .load("https://s3-ea-east-8.amazonaws.com/music/MusicApp_3.jpg")
                .placeholder(R.drawable.img_placeholder)
                .memoryPolicy(MemoryPolicy.NO_CACHE)
                .networkPolicy(NetworkPolicy.NO_CACHE)
                .into(imageView);

通过使用以上代码,图像在安装应用程序后仅第一次显示.下次仅显示占位符图片

By using above code image is displaying only very first time after installing app. next time its only showing placeholder image

我正在使用此库来显示图像.

I am using this library for displaying image.

问题不在于毕加索,而是从私有" URL加载图像.

The problem isn't with Picasso, it's with loading an image from a "private" url.

请提出解决方案

推荐答案

您需要从S3客户端生成一个预签名的网址,然后可以将该网址传递给毕加索. 该网址将是公开的,并有一个有效日期.

You need to generate a presigned Url from S3 client and you can pass that url to picasso. That url will be public and will have an expriy date.

这篇关于如何通过具有私人访问权限的Picasso从AWS加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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