Using WWW class to get multiple urls

I have several models (.obj) in my server and I want to get the URLs of all of them. I know in c# there’s Directory.GetFiles but that’s not usable, i also know WWW can get one of the models with a URL but I want all of them.

The models are stored inside a folder called Models, is there anyway to get all of their urls or something similar so that I can load them using an .obj loader.

Your best shot would be to download a json file from the server with all the urls you need to download.

As a result, your application only knows one url, for the json file. This also allows to modify the models without the need to ship a new version of the app.

{
"models":[ "models/modelA.obj", "models/modelB.obj",]
}

[Serializable]
public class RootObject{
     public string [] models;
}
public class ParseJson:MonoBehaviour{
    string url = "http://myurl.com/"
    IEnumerator Start()
   {
        WWW www = new WWW(url+"data.json");
       yield return www;
       // Check if all valid
       RootObject ro = JsonUtility.Deserialize<RootObject>(www.text);
      foreach(string modelUrl in ro.models){
           WWW newWWW = new WWW(Path.Combine(url, modelUrl));
           yield return  www;
          // Continue with models and checking
     }
   }
}

This is quite of a fastened version. The top is the json file that you download. It contains the two urls for two models. This is the file you would modify to add, remove models or other type of data.

Then the code simply reads the content to download the required assets.

The other way is AssetBundle:

zip your files and upload to your database and download the file zip in your app and unzip it…it’s very simple…
here is the unzip code…
you must put the ZipFile.cs in your project and after that you get your zip file form url and just write ZipFile.Unzip(path,www.byte);

public class unzip : MonoBehaviour{

IEnumerator DownloadandUnzip(){

 UnityWebRequest www = UnityWebRequest.Get("yourURL.zip");
        yield return www.SendWebRequest();
        if (www.error!=null)
        {
            Debug.Log(www.error);
        }
        else
        {
            byte[] data = www.downloadHandler.data; 
            ZipFile.UnZip(Application.persistentDataPath, data);
        }
}

this is the GitHub link for asset: