public async Task <FileResponse> CreateFileAsync(string container, string filepath, string content, bool checkExists = true) { if (container == null) { throw new ArgumentNullException("container"); } if (filepath == null) { throw new ArgumentNullException("filepath"); } if (content == null) { throw new ArgumentNullException("content"); } IHttpAddress address = baseAddress.WithResource(container, filepath).WithParameter("check_exist", checkExists); IHttpRequest request = new HttpRequest(HttpMethod.Post, address.Build(), baseHeaders.Exclude(HttpHeaders.ContentTypeHeader), content); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var data = new { file = new List <FileResponse>() }; return(contentSerializer.Deserialize(response.Body, data).file.First()); }
/// <summary> /// Initializes a new instance of the <see cref="HttpRequest"/> class. /// </summary> /// <param name="method">HTTP method.</param> /// <param name="url">URL.</param> /// <param name="headers">Headers collection.</param> public HttpRequest(HttpMethod method, string url, IHttpHeaders headers) { HttpUtils.CheckUrlString(url); if (headers == null) { throw new ArgumentNullException("headers"); } Method = method; Url = url; Headers = headers.Exclude(HttpHeaders.ContentTypeHeader); }