Search Unity

How many slashes are after file:// protocol for www and UnityWebRequest?

Discussion in 'Scripting' started by cdytoby, Oct 18, 2017.

  1. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    It was different for different Unity version, I need to know the current status on Unity 2017.2.0

    Windows Desktop: file://C:/... (2 slashes, it was 3 slashes before Unity 2017)

    iOS: file:///var/... (2 slashes, because persistantdatapath returns with 1 slash. However, it doesn't work in Unity 2017.2.0, www returned 404.)

    Android: file:///storage/....(2 slashes, because persistantdatapath returns with 1 slash. no issue.)

    Windows Phone: file://C:/... (2 slashes)

    Are these correct? How to solve iOS file issue? should it be file://var or file:///var?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There are always two slashes in file://, just like there are always two slashes in http:// and ftp://. Whatever is after that depends on the path. All Unix-based operating systems use "/" for the root (so, everything except Windows basically). The only way file://var would work is if there's a folder called var in the current path, which is unlikely since presumably you're trying to get the var folder in root, which is /var.

    --Eric
     
  3. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    You missed my point. I typed "..." at every location(I forgot the last two.). iOS persistant data path returns with /var at the beginning, so I type var.

    and after some test, I find out that iOS should be file:///var/... . two slash plus persistant data path.

    Now I have another question: There was an issue long time ago, that on iOS, load a string from url using www will be unconditionally cached. And when I change the content inside the url, www will not load the newest string, but the old cached one, even when I call a method that disable www cache. I have to add a parameter after the url like ?p=20171017123015468, so that iOS think that this is a new url. Is this bug already fixed?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I didn't miss your point at all...I know that /var isn't the complete path; it wasn't relevant. If you read what I said, it answered your question.

    --Eric
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    According URI specification there should always be 3 slashes. You have file:// followed by absolute path. It is somewhat confusing on Windows, as paths here don't start with slash, yet the proper URI on Windows is in fact file:///C:/...
    It is a common error to put only 2 slashes on Windows and some software does support that.
    I recommend using System.Uri class to create file URIs, you won't need to deal with system then and will get tahe conformant URIs.