How do I retrieve a binary file with UnityWebRequest?

I’m building a game for WebGL.

My main goal is to save and load data from a binary file from my StreamingAssets folder.

I’ve read the documentation that says that I need to use UnityWebRequest for that, but it really doesn’t explains anything…

I mostly don’t understand how do I de-serialize my binary file and then serialize it again and use a web request to save it back.

Can I access it from UnityWebRequest.downloadHandler?

This is what I use to get level files stored as either binary or text. Then I do this to call the subroutine. But this is a windows project not a webgl one if that makes any difference. Also I don’t know of the StreamingAssets folder, this works on an url.

StartCoroutine(GetLevelFile(szMapFile, true));

You will have to write something similar to upload the file. How to create your binary data you can look up elsewhere.

internal string szLevelTextData;
internal byte[] aLevelBinaryData;
public IEnumerator GetLevelFile(string i_szFilename, bool i_bBinary)
    bIsDone = false;

    string url = WEB_HOST + "/user_levels/" + i_szFilename;
    www = UnityWebRequest.Get(url);
    yield return www.SendWebRequest();

    if (www.isNetworkError || www.isHttpError)
        if (!i_bBinary) szLevelTextData = www.downloadHandler.text;
        else aLevelBinaryData =;
    bIsDone = true;