i connect to AWS(Amazon WebService) and read data from specific table and from within data S3Link object used this object to return image for each item some image not return because SocketTimeoutException
@Override
protected List<Item> doInBackground(Void... params) {
itemList= ItemOperation.getItemList(); // get data from Amazon
Log.e(TAG,itemList.size()+"");
return itemList;
}
@Override
protected void onPostExecute(List<Item> items) {
new DownloadImage().execute(items);
}
}
public class DownloadImage extends AsyncTask<List<Item>,Void,Void>{
@Override
protected Void doInBackground(List<Item>... params) {
AmazonS3Client s3Client=new AmazonS3Client(Constants.MANAGER.getCredentials());
InputStream myObjectBytes=null;
S3Object getResponse=null;
GetObjectRequest getRequest;
for (int i=0;i<params[0].size();i++) {
String bucketName= params[0].get(i).getItemPhoto1().getBucketName();
String pictureId= params[0].get(i).getItemPhoto1().getKey();
getRequest = new GetObjectRequest(bucketName,pictureId);
getResponse = s3Client.getObject(getRequest);
myObjectBytes = getResponse.getObjectContent();
itemList.get(i).setBitmap(BitmapFactory.decodeStream(myObjectBytes));
}
try {
myObjectBytes.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Aucun commentaire:
Enregistrer un commentaire