2017-10-19 102 views
0

我在android中使用transferutility mehtod從亞馬遜s3存儲桶下載圖像。上傳工作正常。但是在下載時,它給我一個錯誤,同時圖像與我提供的相同密鑰在存儲桶中。無法從android s3中通過TransferUtility獲取圖像android

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

看起來像是404錯誤的圖像,鍵或值。 –

回答

0

我發現這個問題。實際上從s3下載了多個圖像。之後,下載功能執行後,它會在後臺運行,直到所有圖像下載。我有一個代碼在圖像視圖中設置圖像。所以問題是圖像還沒有下載,並且代碼顯示它們之前運行。這就是爲什麼我沒有得到任何圖像。