Search Unity

[Solved]Downloading AssetBundle from server 404 error

Discussion in 'Multiplayer' started by Feidry, Nov 11, 2019.

  1. Feidry

    Feidry

    Joined:
    Nov 8, 2013
    Posts:
    5
    Hello,
    I'm having some trouble downloading an asset bundle from a web server. I can go to the website in my browser and download the file with no issues there and the asset bundle can be loaded from disk with no issues but when attempting to download the bundle from within the game, it returns a 404 error. I've verified that the URL is correct. The code I used is essentially the same as the code below with variable names changed. Any help is appreciated.

    Code (CSharp):
    1. private IEnumerator GetBundleFromServer(string bundleName)
    2. {
    3.     using (UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(serverURL + bundleName)
    4. {
    5.     yield return request.SendWebRequest();
    6.    
    7.     if (request.isNetworkError || request.isHttpError)
    8.     {
    9.         Debug.Log(request.error);
    10.     }
    11.     else
    12.     {
    13.         asset = DownloadHandlerAssetBundle.GetContent(request);
    14.     }
    15. }
    16. }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd output the full URL (serverURL + bundleName) to Debug.Log, copy it from the log file itself (not retype it), and paste it into the browser to verify the URL is good, because if you're getting a 404 error that's the most likely cause still.
     
  3. Feidry

    Feidry

    Joined:
    Nov 8, 2013
    Posts:
    5
    Yeah, I did that. Same thing. I can download it in my browser but for whatever reason, Unity won't.
     
  4. Feidry

    Feidry

    Joined:
    Nov 8, 2013
    Posts:
    5
    Turns out it was a letter case issue. The game was looking for upper case letters but they existed on the server as lowercase. Using .ToLower() on the bundleName resolved the issue.
     
    embraiz likes this.