Skip to content

Solid.Http.Extensions.SharpCompress Initialization

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

Initialization

HXRd.Solid.Http.Extensions.SharpCompress is designed to work with Solid.Http and Solid.Http.Core.

SharpCompressOptions

  • ReaderOptions This is the SharpCompress.Readers.ReaderOptions and will be used when the archives are constructed
  • TarArchivesAreGziped It's so common that when we are working with tars, we have a compressed tar, tar.gz. So the default is that if the requested archive is a TarAchive it's assumed that it is a tar.gz. However you can change this default behavior when working with plain tar by setting this property to false
  • useDefaultMimeTypes See MimeTypes here below for the default mimetype list. If this is set to false, there are no default mimetypes. If this is property is set to false, make sure to include at least one mimetype in the MimeType list or you will get an error.
  • MimeTypes The mimetypes that are associated with the extension. If the mimetypes are encountered, the extension will try to create the requested Archive. There are some default mimetypes that are provided by default. These are
"application/zip",
"application/x-rar-compressed",
"application/x-tar",
"application/x-7z-compressed"

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