jgiacomini / Tiny.RestClient

Simpliest Fluent REST client for .NET
MIT License
210 stars 30 forks source link

How to download image and mp4 video files #122

Closed rexn8r closed 2 years ago

rexn8r commented 2 years ago

Hello

how would i download image as well as video files using this package?

var client = new Tiny.RestClient.TinyRestClient(new HttpClient(), "http://localhost:4044"); string filePath = Environment.CurrentDirectory + "\test.png"; FileInfo fileInfo = await client. GetRequest("assets/test.png"). DownloadFileAsync(filePath);

it throws following error;

Tiny.RestClient.HttpException: 'Response status code does not indicate success. Url : http://localhost:4044/assets/test.png, Verb : GET, StatusCode : NotAcceptable, ReasonPhrase : Not Acceptable'

thanks rex

rexn8r commented 2 years ago

ok got it.

header is to be added.

Image Download

var client = new Tiny.RestClient.TinyRestClient(new HttpClient(), "http://localhost:4044/"); string filePath = Environment.CurrentDirectory + "\test.png"; FileInfo fileInfo = await client. GetRequest("assets/test.png"). AddHeader("Accept", "image/png"). DownloadFileAsync(filePath);

video download

var client = new Tiny.RestClient.TinyRestClient(new HttpClient(), "http://localhost:4044/"); string filePath = Environment.CurrentDirectory + "\test.mp4"; FileInfo fileInfo = await client. GetRequest("assets/test.mp4"). AddHeader("Accept", "video/mp4"). DownloadFileAsync(filePath);

thanks rex