TUS Resumable Upload Protocol¶
The framework component is an implementation of the TUS protocol, which is an open protocol for resumable uploads built on HTTP.
Installation¶
If you want to install module;
-
Add the GridLab.Abp.TUS NuGet package to your project:
Install-Package GridLab.Abp.TUS
-
Add the
AbpTusModule
to the dependency list of your module:[DependsOn( //...other dependencies typeof(AbpTusModule) // <-- Add module dependency like that )] public class YourModule : AbpModule { }
Usage¶
Make sure to put UseTus after UseCors before UseRouting and UseAuthorization
This configuration can be done at API host side
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
// ...
app.UseCors();
app.UseRouting();
ITusConfiguration configuration = context.ServiceProvider.GetRequiredService<ITusConfiguration>();
app.UseTus(httpContext => Task.FromResult(configuration.CreateTusConfiguration()));
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseAuthorization();
// ...
}
TUS Options¶
These options allow you to customize the behavior of the TUS service, including enabling/disabling the service, setting storage paths, configuring expiration times, and more.
Configure<AbpTusConfigurationOptions>(options =>
{
options.IsEnabled = true; // By default TUS is disabled.
});
-
IsEnabled: Controls whether the TUS service is enabled or disabled. Default value is false
-
AbsolutePath: Specifies the absolute path for storing uploaded files. Set to a custom path if you want to store files in a different location. Default value is A path combining the application's base directory and a "files" subdirectory.
-
UrlPath: Defines the URL path to listen for uploads. Default value is /file-management/upload. Set to a custom URL path if your application is hosted in a subpath or if you want to change the upload endpoint.
-
RemoteServices: Contains configurations for remote services. Use this property to configure remote TUS services.
-
Expiration: Sets the expiration time for incomplete files. Default value is AbsoluteExpiration of 5 minutes.
-
MetadataParsingStrategy: Determines the strategy for parsing metadata. Default value is MetadataParsingStrategy.AllowEmptyValues. Change to MetadataParsingStrategy.Original for the old format.
-
AllowedExtensions: Specifies the TUS extensions allowed for use by the client. Restrict or allow specific TUS extensions. Default value is TusExtensions.All
-
MaxAllowedUploadSizeInBytes: Sets the maximum upload size in bytes. Default value is null. Allows any size
-
MaxAllowedUploadSizeInBytesLong: Sets the maximum upload size in bytes (long type). Default value is null. Allows any size