Package Description
$ dotnet add package file-upload-helperThe file-upload-helper now supports dependency injection with strategies for various cloud providers:
AddFileWithAWSS3StrategyAddFileWithAzureBlobStrategyAddFileWithFirebaseStorageStrategyAddFileWithLocalFileSystemStrategyfile-upload-helper accelerates .Net development by providing functionalities such as:
wwwroot directory/filesystem.Add the package to your project via nuget.org or use the commands:
dotnet add package file-upload-helper --version 1.3.6Install-Package file-upload-helper -Version 1.3.6public class Demo
{
private readonly IUploadHelperStrategy strategy;
public Demo(IUploadHelperStrategy strategy){
this.strategy = strategy
}
strategy.PutAsync() takes file(IFormFile), directory/path and cancelatioToken and returns uploaded filename/download url.
strategy.RemoveAsync() takes filename to be deleted and directory/path returns true if deletion was successful
}
var builder = WebApplication.CreateBuilder(args);
- To use with AWS S3
builder.Services.AddFileWithAWSS3trategy(new AWSS3Credentials());
Also support the configuration of notification lambda to be triggered by this Bucket events for S3 operation
builder.Services.AddFileWithAWSS3trategy(new AWSS3Credentials(), configure =>
{
configure.LambdaFunctionConfigurations = new List<LambdaFunctionConfiguration>{
new LambdaFunctionConfiguration{
Id = "lambda",
Events = new List<EventType>{"s3:ObjectCreated:Put"},
FunctionArn = builder.Configuration["AWS_LAMBDA_FUNCTION_ARN"]
}
};
});
-To Use with Firebase storage
builder.Services.AddFileWithAFirebaseStorageStrategy(new FirebaseStorageCredentials());
-To Use with Azure Blob storage
builder.Services.AddFileWithAZureBlobStrategy(new AzureCredentials());
-To Use With Local FileSysyem
builder.Services.AddFileWithLocalFileSystemStrategy(builder.Environment);