Exemplo n.º 1
0
        public AsyncOperation _sendReport(Report report)
        {
            report.SetLogs(_logs);
            APIProperties apiProperties = new APIProperties(_connectionURI);
            var           builder       = apiProperties.BaseURI;

            builder.Path = apiProperties.path;

            var www = new UnityWebRequest(builder.ToString())
            {
                method = "POST"
            };

            www.SetRequestHeader("X-Crittr-Client-Key", apiProperties.apiKey);

            byte[] rawReport     = Encoding.UTF8.GetBytes(report.ToJson());
            var    uploadHandler = new UploadHandlerRaw(rawReport);

            www.uploadHandler = uploadHandler;
            www.SetRequestHeader("Content-Type", "application/json");
            www.downloadHandler = new DownloadHandlerBuffer();
            UnityWebRequestAsyncOperation wwwOp = www.SendWebRequest();

            wwwOp.completed += bindSendReportCompleted(report);

            OnReportSend?.Invoke(report);
            return(wwwOp);
        }
Exemplo n.º 2
0
        private UnityWebRequestAsyncOperation _uploadFile(string filename, byte[] data, RefAndMethod uploadLink)
        {
            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();

            formData.Add(new MultipartFormFileSection("attachment_file", data, filename, ""));

            APIProperties apiProperties = new APIProperties(_connectionURI);
            var           url           = apiProperties.BaseURI + uploadLink.href;
            var           www           = UnityWebRequest.Post(url, formData);

            // 60 Seconds timeout.
            www.timeout         = 60;
            www.downloadHandler = new DownloadHandlerBuffer();
            UnityWebRequestAsyncOperation wwwOp = www.SendWebRequest();

            return(wwwOp);
        }