Search code examples
androiddropboxuniversal-image-loader

How use UIL with dropbox http api


This is how a download works(https://www.dropbox.com/developers/documentation/http#documentation-files-download)

curl -X POST https://content.dropboxapi.com/2/files/download 
  --header "Authorization: Bearer myToken" 
  --header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Prime_Numbers.jpg\"}"

As you can see this way let you download different images with same url.

Should I create a new instance for loader every single image? Which it not seems possible because I don't know how many images will I have.


Solution

  • I had realised that displayImage have an expected DisplayImageOptions parameter. So i created one with my custom parameters

    DisplayImageOptions customOptions = new DisplayImageOptions.Builder()
            ...
            .extraForDownloader(headers)
            .build();
    

    Then in loader ensuring path is different every time, I achieve it using #

    path = path+"#"+my_unique_id;
    loader.displayImage(path, view, defaultOptions, listener);