GithubHelp home page GithubHelp logo

birajmainali / ensure-file-type-dotnet Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 12 KB

Nuget package to validate files by its content types which is more accurate.FileTypeValidator don't let users to inject you an invalid file!

Home Page: https://www.nuget.org/packages/FileTypeValidator/

C# 100.00%
filevalidator dotnetcore content-type class-library

ensure-file-type-dotnet's Introduction

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");
        }

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

ensure-file-type-dotnet's People

Contributors

birajmainali avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sandip124

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.