2017-09-26 76 views
4

我试图加载图像存储在aws S3到我的android应用程序使用毕加索,但我得到一个空白的图像,没有在我的logcat错误,并没有从我一般调试相关的代码行。 我们对图片拥有私密访问权限,因此图片网址无法在浏览器上使用。 我需要使用Picasso将图像显示到我的Android应用程序中。但它不起作用。下面如何加载与毕加索aws图像与私人访问

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

我的代码段通过使用上述代码图像被安装的应用程序后仅显示非常第一次。下次只显示占位符图像

我正在使用this library来显示图像。

问题不在于毕加索,它是从一个“私人”网址加载图像。

请提出解决方案

+0

检查您的图像url ...它给服务器找不到.... –

+2

看看这个:https://stackoverflow.com/questions/30941673/retrieving-image-url-with-specific-access-privileges- using-aws-mobile-sdk-for-an –

+0

@VishalVaishnav我在这个问题中添加了虚拟网址。我无法分享原始网址。 –

回答

1

只需使用这样的:

Picasso.with(getApplicationContext()).load(your_url).noFade().into(imageView); 
+2

这不回答OP的问题。问题不在于毕加索,而在于从“私人”网址加载图片。 – nbokmans

+0

@ nbokmans正确 请提出您正在使用的任何答案 –

1
write below code to load image in Picasso. 
variables:- 
String file_path       -->> this is your image file path 
Imageview mViewHolder.img_post_photo  -->> this is your imageview to load image. 
     Picasso.with(context) 
           .load(file_path) 
           .placeholder(R.mipmap.ic_launcher) 
           .error(R.mipmap.ic_launcher) 
           .into(mViewHolder.img_post_photo, new Callback() { 
            @Override 
            public void onSuccess() { 

            } 

            @Override 
            public void onError() { 
             Picasso.with(context) 
               .load(file_path) 
               .placeholder(R.mipmap.ic_launcher) 
               .error(R.mipmap.ic_launcher) 
               .into(mViewHolder.img_post_photo); 
            } 
           }); 
Set dependencies in your app build.gradle file:- 
compile 'com.squareup.picasso:picasso:2.5.2' 

hope this code helps you. 
+1

问题不在于毕加索,而是从“私人”网址加载图像。 –

+0

好的,然后请参考此文档: - https://stackoverflow.com/questions/30941673/retrieving-image-url-with-specific-access-privileges-using-aws-mobile-sdk-for-an – InsaneCat

0

你需要生成从S3客户端presigned URL和可以传递网址到毕加索。 该网址将公开并将有一个expriy日期。