FileTypeValidator 1.0.1

dotnet add package FileTypeValidator --version 1.0.1                
NuGet\Install-Package FileTypeValidator -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FileTypeValidator" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FileTypeValidator --version 1.0.1                
#r "nuget: FileTypeValidator, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FileTypeValidator as a Cake Addin
#addin nuget:?package=FileTypeValidator&version=1.0.1

// Install FileTypeValidator as a Cake Tool
#tool nuget:?package=FileTypeValidator&version=1.0.1                

FileTypeValidator

FileTypeValidator do not allow users to inject invalid file. It validate files by its content types which is more accurate. Also it is easy to use. After using FileTypeValidator we can validate file by contact types such as Image,Audio,Video and document/text.

Configuration

Di configuration for dotnet 6 project.

  var builder = WebApplication.CreateBuilder(args);
  builder.Services.UseFileTypeValidator();

Di configuration for dotnet 5 project C# 10.

  public void ConfigureServices(IServiceCollection services) 
  {
      services.UseFileTypeValidator();
   }
        

Usage

Dependency injection


    private readonly IFileTypeValidator _fileTypeValidator;

    public HomeController(IFileTypeValidator fileTypeValidator)
    {
        _fileTypeValidator = fileTypeValidator;
    }
    if (!_fileTypeValidator.IsAudio(fileName))
        {
            throw new Exception("Invalid file for audio");
        }

Avliable methods to validate file content are IsImage,IsVideo,IsAudio and IsDocument.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 563 1/23/2022
1.0.0 415 1/23/2022