Hi there.
I need to check if the local file is the same as the online file before download it, that way I will know if I have to update the file or not.
Is there a way to do that?
Cheers and thanks in advance!
Hi there.
I need to check if the local file is the same as the online file before download it, that way I will know if I have to update the file or not.
Is there a way to do that?
Cheers and thanks in advance!
You could have a manifest on your web server that contains the version of the file. If the file online is more recent that the local, download it. You still have to call WWW but you don’t have to download your all file again.(I assume it’s a big file). BTW comparing the size of the files is not very secure. If you change something on the new file but it still have the same size, it will not work
you can also cheat a bit: we do expose WWW implementation in trampoline and we read headers in there - so you can tweak both server to send out something in headers and native impl to check for “version”. But if you are not that comfortable with objc - just go with manifest - that should work just fine
Thanks both, I have to stay as Unity native as possible because this app goes to ios and android.
Yes, the manifest solution was one option, in fact I’m working with xml’s so having some kind of comparisson between the old xml and the new xml could solve the problem, but I was wondering if there was a way to compare online files to local files without having to download them, and the size check was an idea, others were compare creation data and such things, but it’s not possible, so i think I will have to work with xml data.
Cheers and thanks!
It is possible, check this example, it returned the file size and downloaded no data to the device.
using (UnityWebRequest uwr = UnityWebRequest.GetTexture(uri))
{
uwr.method = "HEAD";
yield return uwr.Send();
Debug.LogError(uwr.GetResponseHeader("Content-Length"));
Debug.LogError(uwr.downloadedBytes);
}
Like this, but there is a bit more efficient way to do it:
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.Head.html