public static UnityWebRequest Post(string uri, List <IMultipartFormSection> multipartFormSections, byte[] boundary)
        {
            UnityWebRequest unityWebRequest = new UnityWebRequest(uri, "POST");

            byte[] data = UnityWebRequest.SerializeFormSections(multipartFormSections, boundary);
            unityWebRequest.uploadHandler = new UploadHandlerRaw(data)
            {
                contentType = "multipart/form-data; boundary=" + Encoding.UTF8.GetString(boundary, 0, boundary.Length)
            };
            unityWebRequest.downloadHandler = new DownloadHandlerBuffer();
            return(unityWebRequest);
        }
Esempio n. 2
0
 private static void SetupPost(UnityWebRequest request, List <IMultipartFormSection> multipartFormSections, byte[] boundary)
 {
     byte[] data = null;
     if (multipartFormSections != null && multipartFormSections.Count != 0)
     {
         data = UnityWebRequest.SerializeFormSections(multipartFormSections, boundary);
     }
     request.uploadHandler = new UploadHandlerRaw(data)
     {
         contentType = "multipart/form-data; boundary=" + Encoding.UTF8.GetString(boundary, 0, boundary.Length)
     };
     request.downloadHandler = new DownloadHandlerBuffer();
 }