To download packages from server I use code like this
void SomeFunction()
{
StartCoroutine(DownloadPackage());
}
IEnumerator DownloadPackage()
{
WWW www = new WWW("http://someserver.com/package.zip");
yield return www;
byte[] package = www.bytes;
File.WriteAllBytes("Some/Directory/package.zip",package);
}
And I have a problem!
Almost always i have an error
“You are trying to load data from a www stream which had the following error when downloading.
transfer closed with N bytes remaining to read”
I try to find problem! What it could be? Or it is problem in Unity, or it is problem in internet connection, or server problem!
I try to download this package using web browser and everything good! So I think, that server works perfectly!
So, how to solve this problem? And is there any alternative methods to download files from internet?