public async Task <HttpRequestMessage> Create(string uri)
            {
                var req = HttpRequestHelper.CreateHttpWebRequest(uri, true);

                _multipartMimeRequestHelper.Init(req);

                if (_filter != null)
                {
                    await _filter(req);
                }

                _multipartMimeRequestHelper.Open();
                _multipartMimeRequestHelper.AddXmlRequest(_xmlDoc);
                _multipartMimeRequestHelper.AddFile(_filename);
                _multipartMimeRequestHelper.Close();

                using (var stream = new FileStream(_filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    return(await _multipartMimeRequestHelper.SendRequest(stream));
                }
            }
示例#2
0
            public HttpWebRequest Create(string uri)
            {
                HttpWebRequest req = HttpRequestHelper.CreateHttpWebRequest(uri, true);

                _multipartMimeRequestHelper.Init(req);

                if (_filter != null)
                {
                    _filter(req);
                }

                _multipartMimeRequestHelper.Open();
                _multipartMimeRequestHelper.AddXmlRequest(_xmlDoc);
                _multipartMimeRequestHelper.AddFile(_filename);
                _multipartMimeRequestHelper.Close();

                using (CancelableStream stream = new CancelableStream(new FileStream(_filename, FileMode.Open, FileAccess.Read, FileShare.Read)))
                {
                    return(_multipartMimeRequestHelper.SendRequest(stream));
                }
            }