Downloading a file with coroutine.

Hi,

When i try to download a file from out webserver, most of the time.
It will only create/recive a 1kb file.

Any idea why ?

private IEnumerator FileDownloader(string FileLink,string name)
    {
        Debug.Log("current path " + path);
        DownloadProgress = "";

        Debug.Log("Downloading from "+FileLink);
        WWW www = new WWW(FileLink);    

        while (!www.isDone)
        {
            DownloadProgress = "Downloading " + (www.progress * 100).ToString() + "% ...";
            Debug.Log(DownloadProgress);
            yield return null;
        }

               DownloadProgress = "100 % "+name;

               Debug.Log(DownloadProgress);

               File.WriteAllBytes(path + "//" + name + ".pdf",www.bytes);
    }

Please, use code tags when posting code.
Is www .error!=null and what does it say if it is?

Hi,

I add the code tag now :slight_smile:

Nothing happen.
It goes from 0% to 100% almost instant.

Im trying to download a pdf.

Take a look at UnityWebRequest.Get method, it looks like what you need http://docs.unity3d.com/ScriptReference/Experimental.Networking.UnityWebRequest.html