Error downloading an Asset Bundle from server

Hi all,
I’m trying to download, unpack and use an Asset Bundle from a server, but I get the following error:

Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle “https://addressname.it/test/assetbundleprova.unitypackage

If I try to do the same but with the Asset Bundle saved in a local folder, then it works perfectly.

Here is the code I’m using (took from this Unity guide [5.6 DRAFT] Asset Bundles Documentation - Google Docs):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;

public class DownloadAssetBundles : MonoBehaviour {

    public Button download;
    private string assetBundleName = "assetbundleprova.unitypackage";

    private void Start() {
        download.onClick.AddListener(() => StartCoroutine(InstantiateObject()));
    }

    private IEnumerator InstantiateObject() {
        string uri = "https://addressname.it/test/" + assetBundleName;
        Debug.Log("uri: " + uri);

        UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequest.GetAssetBundle(uri, 0);
        yield return request.Send();

        AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);

        GameObject sphere = bundle.LoadAsset<GameObject>("SphereProva");

        GameObject obj = Instantiate(sphere);
        obj.transform.position = new Vector3(0, 0, 0);
    }
}

How could I resolve this? I found other answers to similar questions but they didn’t fit my needs.

Thanks in advance and have a nice day!

One possible issue is make sure when uploading to the server that you are uploading as binary and not as ascii.

Also make sure your asset bundles are built for the correct device. (Android bundles for android, iOS for iOS, etc)

Also it’s interesting you have a file extension on your assetbundle. None of mine have a file extension of unitypackage.

Thank you for the answer, however I tried to upload the file on another local server and it worked! Maybe it was a matter of permissions or something like that.

Have u find the solution for the issue , i am also not able to download asset bundle from server , but locally its working fine

1 Like

How did you solve that problem?I have same problem too.Would you write your solution here? :slight_smile:

1 Like