java - Setting key for picasso for S3 Amazon -
i trying use amazon s3 client files uploading , downloading. caching trying use picasso right now.
there few points note. 1- in s3, there no single link file. have randomly generate url each image. url expire in 1 min or can set expire in 1 hour.
in oncreateview of adapter calling this
string url = getamazontempurl()
2- each file name same can modified on server. e.g abc.png file name , can 1mb today , tomorrow there 1 more image there.
now want ask how can picasso handle key such scenario. url changing time in single scroll. name same. not want picasso check name , don't download new updated file.
what want keep cache of generated urls in hashmap, , if there no value key, generate url getamazontempurl()
, store in cache.
if set url expiry time hour can record activity load time variable, , check if has been longer hour. if so, clear cache.
what can do callback picasso in case image fails , recreate url:
picasso.with(this).load(imageurl).into(imgaeview, new callback() { @override public void onsuccess() { } @override public void onerror() { //recreate url here , store in cache } } );
edit:
so in case persist above cache , load next time app started. deal image changing under same url can try dirty way or clean way.
the clean way change url image if can. if that's not option - can perhaps check image's last modified date , append timestamp on url. e.g http://www.sample.com/image.jpg?14869246263 - works fine picasso's cache long the url same.
the dirty way load cached version , after force-reload same image around cache (used done skipcache() believe, deprecated in favour of somethingcachepolicy).
Comments
Post a Comment