Skip to content

Commit cd77076

Browse files
committed
Update README.me
1 parent 51c70f2 commit cd77076

File tree

3 files changed

+112
-9
lines changed

3 files changed

+112
-9
lines changed

FileTypeChecker.Web/FileTypeChecker.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<LangVersion>8.0</LangVersion>
66
<PackageId>File.TypeChecker.Web</PackageId>
7-
<Version>1.0.0</Version>
7+
<Version>1.1.0</Version>
88
<Title>FileTypeChecker.Web</Title>
99
<Authors>Aleksandar J. Mitev</Authors>
1010
<Company>Aleksandar J. Mitev</Company>

FileTypeChecker.Web/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## How to install?
2+
3+
If you are working on a web project like MVC or WebApi this library will provide you with all validation attributes you needed for easy data validation. You can install this library using NuGet into your project.
4+
5+
```nuget
6+
Install-Package File.TypeChecker.Web
7+
```
8+
9+
or by using dotnet CLI
10+
11+
```
12+
dotnet add package File.TypeChecker.Web
13+
```
14+
15+
## How to use?
16+
17+
This library will provide you with five powerful and easy to use validation attributes. They will give you the power to allow or forbid any supported type of file. For example you can restrict your users to be able to upload only images or only archives just by setting an attribute into your method or class.
18+
19+
All validation attributes should be used over IFormFile interface and can be used in a class over property or with method parameter.
20+
21+
- AllowImageOnly: This validation attribute will restrict IFormFile to be only image format like jpg, gif, bmp, png and tiff
22+
- AllowArchiveOnly: This validation attribute will restrict IFormFIle to be only archive format.
23+
- AllowedTypes: This validation attribute will allow you to specify what types of file you want to recive from user. We advice you to use FileExtension class to specify the extension string.
24+
- ForbidExecutableFile: This validation attribute will forbid your users to upload executable files.
25+
- ForbidTypes: This validation attribute will allow you to specify what types of file you don't want to recive from user. We advice you to use FileExtension class to specify the extension string.
26+
27+
```c#
28+
[HttpPost("filesUpload")]
29+
public IActionResult UploadFiles([AllowImageOnly] IFormFile imageFile, [AllowArchiveOnly] IFormFilarchiveFile)
30+
{
31+
// Some cool stuf here ...
32+
}
33+
```
34+
35+
```c#
36+
using FileTypeChecker.Web.Attributes;
37+
38+
public class InputModel
39+
{
40+
[AllowImageOnly]
41+
public IFormFile FirstFile { get; set; }
42+
43+
[AllowArchiveOnly]
44+
public IFormFile SecondFile { get; set; }
45+
46+
[AllowedTypes(FileExtension.Bitmap)]
47+
public IFormFile ThirdFile { get; set; }
48+
49+
[ForbidExecutableFile]
50+
public IFormFile FourthFile { get; set; }
51+
52+
[ForbidTypes(FileExtension.Doc)]
53+
public IFormFile FifthFile { get; set; }
54+
}
55+
```
56+
57+
If you are interested in finding more samples please use our [wiki page](https://github.com/AJMitev/FileTypeChecker/wiki/How-to-use%3F).

README.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<h1><img src="https://raw.githubusercontent.com/AJMitev/FileTypeChecker/master/tools/FileTypeCheckerLogo-150.png" align="left" alt="FileTypeChecker" width="90">FileTypeChecker - Don't let users to inject you an invalid file</h1>
22

3-
4-
| Project | Build Status | Nuget Package |
5-
|---------------------|--------------|---------------|
6-
| FileTypeChecker | [![Build status](https://ci.appveyor.com/api/projects/status/jx9bcrxs95srhxsj?svg=true)](https://ci.appveyor.com/project/AJMitev/filetypechecker) | [![NuGet Badge](https://buildstats.info/nuget/File.TypeChecker)](https://www.nuget.org/packages/File.TypeChecker/) |
7-
| FileTypeChecker.Web | [![Build status](https://ci.appveyor.com/api/projects/status/jx9bcrxs95srhxsj?svg=true)](https://ci.appveyor.com/project/AJMitev/filetypechecker) | [![NuGet Badge](https://buildstats.info/nuget/File.TypeChecker.Web)](https://www.nuget.org/packages/File.TypeChecker.Web/) |
8-
9-
103
## Project Description
114

12-
FileTypeChecker is a easy to use library that allows you to identify type of file. This will help you to validate all files that are provided by external sources.
5+
FileTypeChecker is a easy to use library that provides quality identification of a file type. This will help you to secure your applications and validate all files that are provided by external sources with few lines of code.
6+
7+
| Project | Build Status | Nuget Package |
8+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
9+
| FileTypeChecker | [![Build status](https://ci.appveyor.com/api/projects/status/jx9bcrxs95srhxsj?svg=true)](https://ci.appveyor.com/project/AJMitev/filetypechecker) | [![NuGet Badge](https://buildstats.info/nuget/File.TypeChecker)](https://www.nuget.org/packages/File.TypeChecker/) |
10+
| FileTypeChecker.Web | [![Build status](https://ci.appveyor.com/api/projects/status/jx9bcrxs95srhxsj?svg=true)](https://ci.appveyor.com/project/AJMitev/filetypechecker) | [![NuGet Badge](https://buildstats.info/nuget/File.TypeChecker.Web)](https://www.nuget.org/packages/File.TypeChecker.Web/) |
1311

1412
## Why to use it?
1513

@@ -33,6 +31,20 @@ or by using dotnet CLI
3331
dotnet add package File.TypeChecker
3432
```
3533

34+
If you are working on a web project like MVC or WebApi use [File.TypeChecker.Web](https://www.nuget.org/packages/File.TypeChecker.Web/). This web library will provide you with all validation attributes you needed for easy data validation. Again You can install it by using NuGet
35+
36+
You can install this library using NuGet into your project.
37+
38+
```nuget
39+
Install-Package File.TypeChecker.Web
40+
```
41+
42+
or by using dotnet CLI
43+
44+
```
45+
dotnet add package File.TypeChecker.Web
46+
```
47+
3648
## How to use?
3749

3850
```c#
@@ -53,6 +65,40 @@ using (var fileStream = File.OpenRead("myFileLocation"))
5365
}
5466
```
5567

68+
### Web Application
69+
70+
With web package you will recive access to our validation attributes that will gives you easy and powerfull way to allow or forbid file types. For example you can restrict your users to be able to upload only images or only archives just by setting an attribute into your method or class.
71+
72+
```c#
73+
[HttpPost("filesUpload")]
74+
public IActionResult UploadFiles([AllowImageOnly] IFormFile imageFile, [AllowArchiveOnly] IFormFilarchiveFile)
75+
{
76+
// Some cool stuf here ...
77+
}
78+
```
79+
80+
```c#
81+
using FileTypeChecker.Web.Attributes;
82+
83+
public class InputModel
84+
{
85+
[AllowImageOnly]
86+
public IFormFile FirstFile { get; set; }
87+
88+
[AllowArchiveOnly]
89+
public IFormFile SecondFile { get; set; }
90+
91+
[AllowedTypes(FileExtension.Bitmap)]
92+
public IFormFile ThirdFile { get; set; }
93+
94+
[ForbidExecutableFile]
95+
public IFormFile FourthFile { get; set; }
96+
97+
[ForbidTypes(FileExtension.Doc)]
98+
public IFormFile FifthFile { get; set; }
99+
}
100+
```
101+
56102
If you are interested in finding more samples please use our [wiki page](https://github.com/AJMitev/FileTypeChecker/wiki/How-to-use%3F).
57103

58104
## What types of file are supported?

0 commit comments

Comments
 (0)