예제 #1
0
        /// <summary>
        /// Post image data on server
        /// </summary>
        /// <param name="image">Image data</param>
        /// <param name="type">Image extension type</param>
        /// <param name="param">Recognize params</param>
        public void PostImage(byte[] image, ImgType type, RecognizeParams param = null)
        {
            if (image == null || image.Length == 0)
            {
                throw new ArgumentException("Bad image data");
            }

            List <KeyValuePair <string, string> > postParams = new List <KeyValuePair <string, string> >();

            postParams.Add(new KeyValuePair <string, string>("method", "post"));
            postParams.Add(new KeyValuePair <string, string>("key", ACCOUNT_ID));

            if (param != null)
            {
                foreach (var keyValue in param.Params)
                {
                    postParams.Add(keyValue);
                }
            }

            byte[] fbData = BuldFormbasedData(postParams, StreamEncoding.GetString(image), type);

            string        contentType = "multipart/form-data; boundary=" + _boundary;
            RequestParams reqParams   = new RequestParams(null, null, contentType, null, true, "POST", StreamEncoding, false);
            DownloaderObj obj         = new DownloaderObj(_postUri, EndPostImage, true, null, CookieOptions.Empty, 4, null, null, false, 1000, null, reqParams);

            obj.PostData = fbData;
            Downloader.Queue(obj);
        }
예제 #2
0
        /// <summary>
        /// Post image data on server
        /// </summary>
        /// <param name="image">Image data</param>
        /// <param name="type">Image extension type</param>
        /// <param name="param">Recognize params</param>
        public void PostImage(byte[] image, ImgType type, RecognizeParams param = null)
        {
            if (image == null || image.Length == 0)
                throw new ArgumentException("Bad image data");

            List<KeyValuePair<string, string>> postParams = new List<KeyValuePair<string, string>>();
            postParams.Add(new KeyValuePair<string, string>("method", "post"));
            postParams.Add(new KeyValuePair<string, string>("key", ACCOUNT_ID));

            if (param!=null)
            {
                foreach (var keyValue in param.Params)
                {
                    postParams.Add(keyValue);
                }
            }

            byte[] fbData = BuldFormbasedData(postParams, StreamEncoding.GetString(image), type);

            string contentType = "multipart/form-data; boundary=" + _boundary;
            RequestParams reqParams = new RequestParams(null, null, contentType, null, true, "POST", StreamEncoding, false);
            DownloaderObj obj = new DownloaderObj(_postUri, EndPostImage, true, null, CookieOptions.Empty, 4, null, null, false, 1000, null, reqParams);
            obj.PostData = fbData;
            Downloader.Queue(obj);
        }