Skip to content

Solid.Http.Extensions.SharpCompress Initialization

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

Initialization

Solid.Http.Extensions.Zip is designed to work with Solid.Http and Solid.Http.Core. The default mimetypes are

"application/zip",
"application/x-rar-compressed",
"application/x-tar",
"application/x-7z-compressed"

and will be installed by default, you can how ever chose not to have the installed provide your own with the mimeType list. The useDefaultMimeTypes flag in the SharpCompressOptions changes this behavior. If useDefaultMimeTypes is set to true and the mimeTypes list is provided, these mimetypes are additional mimetypes to the default ones.

With Solid.Http.Core

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddSolidHttpCore()
            .AddSharpCompress();
    }
}
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddSolidHttpCore()
            .AddSharpCompress(
                new SharpCompressOptions(
                    options: new ReaderOptions
                    {
                        LookForHeader = false
                    },
                    mimeTypes: new List<string>()
                    {
                        "application/octet-stream"
                    },
                    useDefaultMimeTypes: false,
                    tarArchivesAreGziped: false
                )
            );
    }
}

With Solid.Http

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddSolidHttp()
            .AddSharpCompress();
    }
}
public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddSolidHttp()
            .AddSharpCompress(
                new SharpCompressOptions(
                    options: new ReaderOptions
                    {
                        LookForHeader = false
                    },
                    mimeTypes: new List<string>()
                    {
                        "application/octet-stream"
                    },
                    useDefaultMimeTypes: false,
                    tarArchivesAreGziped: false
                )
            );
    }
}

Clone this wiki locally