Quiron.UploadFile
1.0.0
dotnet add package Quiron.UploadFile --version 1.0.0
NuGet\Install-Package Quiron.UploadFile -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="Quiron.UploadFile" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Quiron.UploadFile" Version="1.0.0" />
<PackageReference Include="Quiron.UploadFile" />
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 Quiron.UploadFile --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Quiron.UploadFile, 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 Quiron.UploadFile@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=Quiron.UploadFile&version=1.0.0
#tool nuget:?package=Quiron.UploadFile&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
What is the Quiron.UploadFile?
A package used to easily upload files. It also allows them to be easily extended in your project.
Give a Star! ⭐
If you find this project useful, please give it a star! It helps us grow and improve the community.
Namespaces and Dependencies
- ✅ Quiron.UploadFile
- ✅ Microsoft.AspNetCore.Http
Basic Usage
Protected Properties
protected virtual string[] AllowExtensions => ["image/jpeg", "image/png", "image/jpg"];
protected virtual long MaxSize => 5 * 1024 * 1024;
- ⚠️ You can override these properties when needed.
One File
public async virtual Task<string> File(IFormFile? file, params string[] folders)
{
if (file is null)
throw new UploadException("File not informed.");
if (!AllowExtensions.Contains(file.ContentType))
throw new UploadTypeException("Invalid file type. Please enter only currently allowed extensions.");
if (file.Length > MaxSize)
throw new UploadMaxSizeException($"The size of the file '{file.FileName}' exceeds the {MaxSize}MB limit.");
var urlResult = string.Empty;
try
{
var parentPath = Directory.GetParent(Directory.GetCurrentDirectory());
var solutionPath = parentPath!.FullName;
var pathOrigin = Path.Combine(solutionPath, folders.PathCombane());
if (!Directory.Exists(pathOrigin)) Directory.CreateDirectory(pathOrigin);
var fileName = $"{Guid.NewGuid()}_{Path.GetFileName(file.FileName)}";
var filePath = Path.Combine(pathOrigin, fileName);
using var stream = new FileStream(filePath, FileMode.Create);
file.CopyTo(stream);
urlResult = Path.Combine(folders.PathCombane(), fileName);
}
catch (Exception ex)
{
throw new UploadException($"Error uploading file '{file.FileName}'.", ex);
}
return await Task.FromResult(urlResult);
}
Multiple Files
public async virtual Task<string[]> Files(IFormFile[]? files, params string[] folder)
{
if (files is null || files.Length.Equals(0))
throw new UploadException("Please provide at least 1 file to continue!");
var urls = new string[files.Length];
for (int i = 0; i < files.Length; i++)
urls[i] = await this.File(files[i], folder);
return urls;
}
Compatibility
Supports:
- ✅ .NET Standard 2.1
- ✅ .NET 9 through 9 (including latest versions)
- ⚠️ Legacy support for .NET Core 3.1 and older (with limitations)
About
Quiron.UploadFile was developed by EliasRMJ under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
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.0 | 250 | 4/30/2025 |
Create new package.