Glide Version/Integration library (if any): 3.5.2
Issue details/Repro steps:
I just wanted to _force the load of the url from the network every time_, but it's not possible because I get a compile error. The same is true for .signature().
I could understand diskCacheStrategy not being available since it's set to SOURCE in GenericTranscodeRequest.getDownloadOnlyRequest, but signature should work.
Glide load line:
Glide.with(this)
.load("http://url")
//.diskCacheStrategy(DiskCacheStrategy.NONE) // -> downloadOnly fails to compile
.downloadOnly(200, 200)
//.diskCacheStrategy(DiskCacheStrategy.NONE) // -> this line fails to compile
;
Compile error:
Cannot resolve method.
From what I read when doing my tests, downloadOnly() is to force the image to be downloaded into the cache.
So settings a strategy to none seems logically not compatible.
To get image from network into(width,height) is what the documentation says to use (and it works as I use it)
Yes, that's what I stated above, but signature should work, because whatever you download may change between your app's versions or any other outside trigger (date, etc).
Well signature works with into(x,y) and if you just want to force a dl each time DiskCacheStrategy.NONE works too.
I do not see what you want to achieve.
into(w,h) gives you a GlideDrawable while downloadOnly(w,h) gives you a File.
I just wanted to force load the URL every time (see itallic text above), for example if I had a changing image with an unchanging url, like an avatar with displayed reputation points or something.
There's a contradiction in your need, you want to put a file in the cache but do not use it.
Downloadonly give a file from the source cache so it can be reused after as a source cached image.
If the avatar is to be updated each time setting DiskCacheStrategy.NONE in the normal query will force a network download each time.
Why do you need a File ?
It's only a theoretical use case, but imagine this:
I get the File via downloadOnly() on application startup where the signature contains a today's date, because the server updates the reputation in an overnight job. If the user starts the app first time in the morning Glide'll request the image and store it in a file. Then I [optionally store that File reference somewhere global and] use it to for example put a stamp on user-generated content and/or display it. If the user starts the app later that day there's no download because signatures match. The next day a new image is loaded.
As I understand the whole point of downloadOnly is to support use cases like the above.
By the way I opened the bug when I tried to test an OkHttp loading bug without an ImageView, whereby I would have needed to skip the cache every time because I was debugging the networking part.
Hope this clears it up, feel free to close it as invalid if the use case above is highly unlikely.
I'm really not sure to still understand :)
Why not just use all normal glide usage with a signature Key like for example IntegerVersionSignature that will contain the current day.
This sounds way more logical and for me the way signature was added for.
The key here would be "put a stamp on user-generated content", you can't do that without downloading the stamp before attempting to have a transformation on an arbitrary image. It may be far stretching, I recognise that, but I was really puzzled when none of the above methods compiled.
I think signature is legitimate use case for people who specifically want a File back. I'll think about this, it may need to wait until 4.0
Add .listener() to the list, that is .load().listener().downloadOnly() is not possible.
You just need to cast .signature() to be DrawableTypeRequest which inherit from DrawableRequestBuilder, and has the downloadOnly() method, hopefuly it internally should work, I'm just about to test:
((DrawableTypeRequest<String>) Glide.with(context)
.load(url)
.signature(new StringSignature(signature)))
.downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
Sorry to be a bit late, lol...
I believe this is now obsolete in v4.
Yes, v4 deprecated downloadOnly(...), we need to use
GlideApp
.with(this)
.downloadOnly() // this does the trick
.load("http://url")
//.signature/diskCacheStrategy works here
.submit();
Most helpful comment
You just need to cast
.signature()to beDrawableTypeRequestwhich inherit fromDrawableRequestBuilder, and has thedownloadOnly()method, hopefuly it internally should work, I'm just about to test:Sorry to be a bit late, lol...