private static IEnumerator GetFileInformationInternal(string domain, string location, string path, FileInformationCallback callback) { #if LDMT_TESTING_WITHOUT_OCTOPI var json = @" { ""name"": ""BVS.gco"", ""size"": 1468987, ""date"": 1378847754, ""origin"": ""local"", ""refs"": { ""resource"": ""http://example.com/api/files/local/BVS.gco"", ""download"": ""http://example.com/downloads/files/local/BVS.gco"" }, ""gcodeAnalysis"": { ""estimatedPrintTime"": 1188, ""filament"": { ""length"": 810, ""volume"": 5.36 } }, ""print"": { ""failure"": 4, ""success"": 23, ""last"": { ""date"": 1387144346, ""success"": true } } }"; yield return(null); #else UnityWebRequest request = UnityWebRequest.Get(domain + "/api/files/" + location + "/" + path); request.SetRequestHeader("x-api-key", xApiKey); yield return(request.SendWebRequest()); if (request.isHttpError) { callback.Invoke(false, null); } else { var json = System.Text.Encoding.ASCII.GetString(request.downloadHandler.data); #endif FileInformation result = JsonConvert.DeserializeObject <FileInformation>(json); callback.Invoke(true, result); #if !LDMT_TESTING_WITHOUT_OCTOPI } #endif }
public static void GetFileInformation(string domain, string location, string path, FileInformationCallback callback) { Instance.StartCoroutine(GetFileInformationInternal(domain, location, path, callback)); }