Пример #1
0
 private static UnityWebRequest _uploadFile(string url, string sectionName, string fileName, byte[] fileContent, CLAssetType type,
                                            object successCallback, object failedCallback, object orgs, bool isCheckTimeout,
                                            int maxFailTimes, int failedTimes)
 {
     try
     {
         if (string.IsNullOrEmpty(url))
         {
             return(null);
         }
         self.enabled = true;
         MultipartFormFileSection     fileSection = new MultipartFormFileSection(sectionName, fileContent, fileName, "Content-Type: multipart/form-data;");
         List <IMultipartFormSection> multForom   = new List <IMultipartFormSection>();
         multForom.Add(fileSection);
         UnityWebRequest www = UnityWebRequest.Post(url, multForom);
         Coroutine       cor = self.StartCoroutine(
             self.exeWWW(www, url, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes,
                         (url2) =>
         {
             _uploadFile(url2, sectionName, fileName, fileContent, type, successCallback, failedCallback, orgs, isCheckTimeout, maxFailTimes, failedTimes + 1);
         }));
         wwwMap4Get[url] = cor;
         return(www);
     }
     catch (System.Exception e)
     {
         Debug.LogError(e);
         Utl.doCallback(failedCallback, null, orgs);
         return(null);
     }
 }
Пример #2
0
        //protected virtual void OnEnable ()
        //protected virtual void OnDisable ()
        //protected abstract void Update ()

        #endregion

        #region Methods
        //protected virtual bool InitCamera ()
        //protected virtual void StopCamera ()
        //protected virtual void ProcessCameraFrame ()

        // This one does not work because of https and badly support on form-data in UnityWebRequest
        protected UnityWebRequest CreateDirectRequest(byte[] photo)
        {
            //MultipartFormDataSection fn =new MultipartFormDataSection ("f", photo, "image/png") ;
            MultipartFormFileSection     fn       = new MultipartFormFileSection("f", photo, "myimage.png", "image/png");
            List <IMultipartFormSection> formData = new List <IMultipartFormSection> ();

            formData.Add(fn);

            UnityWebRequest client = UnityWebRequest.Post(
                "http://zxing.org/w/decode",
                formData
                );

            return(client);
        }