Search code examples
androidamazon-web-servicesamazon-s3android-imageuniversal-image-loader

Android : Using amazom s3 TransferManager with UIL


I'd like to start using Amazon TransferManager with UIL.
Currentlly i'm using UIL the following way I've extended the BaseImageDownloader class and I provide the input stream

return client.getObject(req).getObjectContent();

and when using the UIL I just provide my downloader class to the UIL configurations.

How can I migrate it to use TransferManager?


Solution

  • TransferManager doesn't give you access to an InputStream while a download is in progress so it may not be a good match for your usage. One approach would be to download to a File first then create an InputStream on that. This example doesn't have exception handling, but shows that approach.

    File outputFile = new File("/path/to/file");
    Download download = transferManager.download(req, outputFile);
    download.waitForCompletion();
    return new FileInputStream(outputFile);