【问题标题】:Unable to get Image from Amazon s3 through TransferUtility in android无法通过 Android 中的 TransferUtility 从 Amazon s3 获取图像
【发布时间】:2018-03-31 04:30:23
【问题描述】:

我在 android 中使用 transferutility mehtod 从 amazon s3 存储桶下载图像。上传工作正常。但是在下载时,当图像在存储桶中且具有我提供的相同密钥时,它会给我一个错误。

E/error: com.amazonaws.services.s3.model.AmazonS3Exception: The specified key does not exist. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey; Request ID: D1B5ACBA8389A6), S3 Extended Request ID: RnoeOgB1TC2AY7AZ+TiMK6C49yUpBcebX2wV0CA6Zy2kl20MTzq+Odo+PLLiBN4a=

我下载图片的代码是:

credentialsProvider();
TransferUtility transferUtility = new TransferUtility(s3Client, getApplicationContext());
file = new File(Environment.getExternalStorageDirectory().toString() + "/" + test_object.getImagesQuestions().get(i).getImageKey());
                                        test_object.getImagesQuestions().get(i).setImage(file);
TransferObserver observer = transferUtility.download(
                            "BucketName",     /* The bucket to upload to */
                             test_object.getImagesQuestions().get(i).getImageKey(),    /* The key for the uploaded object */
                             test_object.getImagesQuestions().get(i).getImage()       /* The file where the data to upload exists */
                             );
transferObserverListener(observer);

【问题讨论】:

  • 在您获得 404 时,图像、键或值看起来有问题。

标签: android amazon-s3 amazon-cognito


【解决方案1】:

我发现了问题。实际上有多个从 s3 下载的图像。在下载功能执行之后,它会在后台运行,直到所有图像下载完毕。我前面有一个代码,可以在 imageview 中设置图像。所以问题是图像尚未下载并且显示它们的代码之前运行过。这就是为什么我没有得到任何图像。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-29
    • 2015-07-27
    • 1970-01-01
    • 2015-11-29
    • 2013-08-24
    • 2011-10-21
    • 1970-01-01
    • 2018-09-24
    相关资源
    最近更新 更多