internal static async Task <IDownloadedFile> GetFile(Common.FileInfo fileInfo, string uri) { var request = new HttpRequestMessage(HttpMethod.Post, uri); using (var client = new HttpClient()) { client.BaseAddress = new Uri(uri); request.Content = new StringContent(Serialization.DataContractSerializeObject <Common.FileInfo>(fileInfo), Encoding.UTF8, "application/xml"); var response = await client.SendAsync(request); var stream = await response.Content.ReadAsStreamAsync(); var buffer = new byte[stream.Length]; var result = await stream.ReadAsync(buffer, 0, (int)stream.Length); var downloadedFileInfo = new DownloadedFileInfo() { Path = Paths.DownloadPath + response.Content.Headers.ContentDisposition.FileName, Name = response.Content.Headers.ContentDisposition.FileName, Buffor = buffer }; return(downloadedFileInfo); } }
internal bool Delete(Common.FileInfo file) { try { File.Delete(file.Path); return(true); } catch { return(false); } }
internal static async Task <HttpResponseMessage> DeleteFile(Common.FileInfo fileInfo, string uri) { var request = new HttpRequestMessage(HttpMethod.Delete, uri); using (var client = new HttpClient()) { client.BaseAddress = new Uri(uri); request.Content = new StringContent(Serialization.DataContractSerializeObject <Common.FileInfo>(fileInfo), Encoding.UTF8, "application/xml"); return(await client.SendAsync(request)); } }
public void Delete([FromBody] Common.FileInfo file) { model.Delete(file); }
public HttpResponseMessage GetFile([FromBody] Common.FileInfo file) { return(FileAsAttachment(file.Path, file.Name)); }
public async Task <IDownloadedFile> GetFile(Common.FileInfo file) { return(await HttpMessageSender.GetFile(file, _endPoint + "get")); }
public async Task <HttpResponseMessage> DeleteFile(Common.FileInfo file) { return(await HttpMessageSender.DeleteFile(file, _endPoint + "delete")); }