SecureFileValidator 1.0.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Framework 4.7
This package targets .NET Framework 4.7. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SecureFileValidator --version 1.0.0
NuGet\Install-Package SecureFileValidator -Version 1.0.0
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="SecureFileValidator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SecureFileValidator" Version="1.0.0" />
<PackageReference Include="SecureFileValidator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SecureFileValidator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SecureFileValidator, 1.0.0"
#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.
#:package SecureFileValidator@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SecureFileValidator&version=1.0.0
#tool nuget:?package=SecureFileValidator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SecureFileValidator
跨平台檔案簽名驗證共用函式庫(支援 .NET 8 + .NET Framework 4.7)
功能特色
- ✅ 驗證檔案內容是否與副檔名相符(Magic Number / File Signature)
- ✅ 支援常見格式:JPG、PNG、PDF、DOCX、XLSX、MP4、ZIP、RAR 等
- ✅ 提供 ASP.NET Core 與 ASP.NET MVC 專用的
ActionFilterAttribute
- ✅ 可用於 API 上傳檔案驗證、資安保護、病毒掃描前置防禦
安裝方式
1. 加入參考
若您從原始碼引入:
dotnet add reference ../SecureFileValidator/SecureFileValidator.csproj
或將它打包為 NuGet 後使用:
dotnet add package SecureFileValidator
2. 在 Controller 中使用
ASP.NET Core (.NET 8 以上)
[HttpPost]
[ValidateFileSignature("file")]
public IActionResult Upload(IFormFile file)
{
return Ok("驗證通過");
}
ASP.NET MVC (.NET Framework)
[HttpPost]
[ValidateFileSignature("file")]
public ActionResult Upload(HttpPostedFileBase file)
{
return Content("驗證通過");
}
支援格式對照表(部分)
副檔名 | 格式 | Magic Number |
---|---|---|
.jpg |
JPEG | FF D8 FF |
.png |
PNG | 89 50 4E 47 |
.pdf |
25 50 44 46 |
|
.docx |
Word (ZIP) | 50 4B 03 04 |
.xlsx |
Excel (ZIP) | 50 4B 03 04 |
.mp4 |
MP4 | ftyp @byte4 |
.exe |
PE EXE | 4D 5A |
.rar |
RAR4/RAR5 | 52 61 72... |
授權
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Framework | net47 is compatible. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7
- Microsoft.AspNet.Mvc (>= 5.2.7)
- System.IO.Compression (>= 4.3.0)
- System.IO.Compression.ZipFile (>= 4.3.0)
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.