Skip to content

Solid.Http.Extensions.SharpCompress Usage

HX-Rd edited this page May 9, 2018 · 7 revisions

Deserializing response content to an archive

Here is a small example on how to get a ZipArhive and read some of its contents. In this example we are going to call nuget.org. The nuget packages are zip files but do not have a zip ending so they do not have the default mimetype.

public class ValuesController : Controller
{
    private SolidHttpClient _client;
    public ValuesController(ISolidHttpClientFactory factory)
    {
        _client = factory.CreateWithBaseAddress("https://www.nuget.org");
    }
    [HttpGet]
    public async Task GetAsync()
    {
        var arch = await client
            .GetAsync("api/v2/package/Solid.Http/1.0.32")
            .As<ZipArchive>();
        return Ok();
    }
}

Clone this wiki locally