Esempio n. 1
0
    IEnumerator Start()
    {
        string url = "https://thexr.co/videos/heaven.mp4";

        string vidSavePath = AndroidPathManager.GetFriendlyFilesPath() + "/" + videoName + ".mp4";

        print(vidSavePath);
        //Create Directory if it does not exist
        if (!Directory.Exists(Path.GetDirectoryName(vidSavePath)))
        {
            Directory.CreateDirectory(Path.GetDirectoryName(vidSavePath));
        }

        var uwr = new UnityWebRequest(url);

        uwr.method = UnityWebRequest.kHttpVerbGET;
        var dh = new UnityEngine.Networking.DownloadHandlerFile(vidSavePath);

        dh.removeFileOnAbort = true;
        uwr.downloadHandler  = dh;
        yield return(uwr.SendWebRequest());

        if (uwr.isNetworkError || uwr.isHttpError)
        {
            Debug.Log(uwr.error);
            errorNetworking.SetActive(true);
        }
        else
        {
            Debug.Log("Download saved to: " + vidSavePath.Replace("/", "\\") + "\r\n" + uwr.error);
        }
    }
Esempio n. 2
0
        private void InternalCreateVFS(string path, bool append)
        {
            string directoryName = Path.GetDirectoryName(path);
            bool   flag          = !Directory.Exists(directoryName);

            if (flag)
            {
                Directory.CreateDirectory(directoryName);
            }
            this.m_Ptr = DownloadHandlerFile.Create(this, path, append);
        }
Esempio n. 3
0
        static public Response Send(
            string url,
            string method,
            string[] headers,
            byte[] body,
            Options options
            )
        {
            var resp = new UnityWebRequest(url);

            if (headers != null)
            {
                for (int i = 0; i < headers.Length; i += 2)
                {
                    resp.SetRequestHeader(headers[i], headers[i + 1]);
                }
            }
            if (method == null)
            {
                if (body != null)
                {
                    resp.method = "POST";
                }
                else
                {
                    resp.method = "GET";
                }
            }
            else
            {
                resp.method = method;
            }
            if (body != null)
            {
                resp.uploadHandler = (UploadHandler) new UploadHandlerRaw(body);
            }
            if (options != null && options.filepath != null)
            {
                var dh = new UnityEngine.Networking.DownloadHandlerFile(options.filepath);
                dh.removeFileOnAbort = true;
                resp.downloadHandler = (DownloadHandler)dh;
            }
            else
            {
                resp.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            }
            return(new ResponseImpl(resp));
        }
    static int set_removeFileOnAbort(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.DownloadHandlerFile obj = (UnityEngine.Networking.DownloadHandlerFile)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.removeFileOnAbort = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index removeFileOnAbort on a nil value"));
        }
    }
    static int get_removeFileOnAbort(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Networking.DownloadHandlerFile obj = (UnityEngine.Networking.DownloadHandlerFile)o;
            bool ret = obj.removeFileOnAbort;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index removeFileOnAbort on a nil value"));
        }
    }
Esempio n. 6
0
 static int QPYX__CreateUnityEngine_Networking_DownloadHandlerFile_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 1)
         {
             string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
             UnityEngine.Networking.DownloadHandlerFile QPYX_obj_YXQP = new UnityEngine.Networking.DownloadHandlerFile(QPYX_arg0_YXQP);
             ToLua.PushSealed(L_YXQP, QPYX_obj_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to ctor method: UnityEngine.Networking.DownloadHandlerFile.New"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Esempio n. 7
0
    // TODO add error handler
    public static void DownloadFileToDisk(string url, string destPath, System.Action onComplete, System.Action <string> onError)
    {
        var req = UnityEngine.Networking.UnityWebRequest.Get(url);

        req.method = UnityEngine.Networking.UnityWebRequest.kHttpVerbGET;
        var downloadHandler = new UnityEngine.Networking.DownloadHandlerFile(destPath);

        downloadHandler.removeFileOnAbort = true;
        req.downloadHandler = downloadHandler;
        req.SendWebRequest().completed += op =>
        {
            if (req.error != null)
            {
                onError?.Invoke(req.error);
            }
            else
            {
                onComplete();
            };
        };
    }
    static int _CreateUnityEngine_Networking_DownloadHandlerFile(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Networking.DownloadHandlerFile obj = new UnityEngine.Networking.DownloadHandlerFile(arg0);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Networking.DownloadHandlerFile.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 private extern static IntPtr Create(DownloadHandlerFile obj, string path);
 private void InternalCreateVFS(string path)
 {
     this.m_Ptr = DownloadHandlerFile.Create(this, path);
 }
Esempio n. 11
0
    static int QPYX_set_removeFileOnAbort_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.Networking.DownloadHandlerFile QPYX_obj_YXQP = (UnityEngine.Networking.DownloadHandlerFile)QPYX_o_YXQP;
            bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2);
            QPYX_obj_YXQP.removeFileOnAbort = QPYX_arg0_YXQP;
            return(0);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index removeFileOnAbort on a nil value"));
        }
    }
Esempio n. 12
0
 private static extern IntPtr Create(DownloadHandlerFile obj, string path, bool append);