Пример #1
0
        //private   Task ProcessPut (HttpClient hc, string putLocation, StreamContent sc)
        //{
        //    var response =   hc.Put (putLocation, sc);
        //    if (response.StatusCode == HttpStatusCode.TemporaryRedirect)
        //    {
        //        var uri = response.Content.Headers.ContentLocation;

        //    }
        //    else
        //    {
        //        response.EnsureSuccessStatusCode();
        //    }
        //}

        /// <summary>
        /// Opens an FSDataOutputStream at the indicated Path. Files are overwritten by default.
        /// </summary>
        /// <param name="localFile"></param>
        /// <param name="remotePath"></param>
        /// <returns></returns>
        public string CreateFile(string localFile, string remotePath)
        {
            WebClient hc  = this.CreateHTTPClient(true);
            var       uri = this.GetUriForOperation(remotePath) + "op=CREATE&overwrite=true";
            //            var resp =   hc.Put (uri, null);
            //            var putLocation = resp.Headers.Location;
            var            putLocation = uri;
            BufferedStream sc          = new System.IO.BufferedStream(System.IO.File.OpenRead(localFile));

            hc.UploadData(putLocation, "PUT", sc.ReadFully());
            return(hc.Headers[HttpResponseHeader.Location].ToString());
        }