Class UploadService
Default implementation of IUploadService that validates files, stores them through the configured provider, and raises upload events.
Inheritance
UploadService
Assembly: CoreUpload.dll
Syntax
public class UploadService : IUploadService
Constructors
UploadService(IUploaderProvider, IUploadProgressService, IOptions<CoreUploadOptions>, IEnumerable<IUploadEventHandler>)
Declaration
public UploadService(IUploaderProvider provider, IUploadProgressService progress, IOptions<CoreUploadOptions> options, IEnumerable<IUploadEventHandler> eventHandlers)
Parameters
Methods
CompleteChunkedUploadAsync(string, string, int, CancellationToken)
Assembles all saved chunks for an upload session, updates progress, and raises the uploaded event for the completed file.
Declaration
public Task<UploadResult> CompleteChunkedUploadAsync(string uploadId, string fileName, int totalChunks, CancellationToken ct = default)
Parameters
Returns
CopyFileAsync(Guid, string, CancellationToken)
Copies an uploaded file to another destination while preserving the original stored upload.
Declaration
public Task CopyFileAsync(Guid fileGuid, string destinationPath, CancellationToken ct = default)
Parameters
Returns
DeleteFileAsync(Guid, CancellationToken)
Deletes a previously uploaded file and its associated metadata.
Declaration
public Task DeleteFileAsync(Guid fileGuid, CancellationToken ct = default)
Parameters
Returns
GetChunkStatusAsync(string, CancellationToken)
Gets the chunk indexes and stored sizes the server currently holds for an
upload session. Returns null when the provider cannot
enumerate chunks (custom providers without GetSavedChunksAsync).
Declaration
public Task<IReadOnlyDictionary<int, long>?> GetChunkStatusAsync(string uploadId, CancellationToken ct = default)
Parameters
Returns
GetFileInfoAsync(Guid, CancellationToken)
Gets metadata for a previously uploaded file.
Returns null when the file cannot be found.
Declaration
public Task<UploadedFileInfo?> GetFileInfoAsync(Guid fileGuid, CancellationToken ct = default)
Parameters
Returns
MoveFileAsync(Guid, string, CancellationToken)
Moves an uploaded file to a permanent destination and removes the original temporary copy.
Declaration
public Task MoveFileAsync(Guid fileGuid, string destinationPath, CancellationToken ct = default)
Parameters
Returns
OpenFileAsync(Guid, CancellationToken)
Opens a readable stream for a previously uploaded file.
The caller is responsible for disposing the returned stream.
Declaration
public Task<Stream> OpenFileAsync(Guid fileGuid, CancellationToken ct = default)
Parameters
Returns
UploadChunkAsync(string, int, int, string, long, Stream, CancellationToken)
Saves one chunk for the supplied upload session.
Validation is performed on the first chunk before any data is persisted.
Declaration
public Task<UploadResult> UploadChunkAsync(string uploadId, int chunkIndex, int totalChunks, string fileName, long totalFileSize, Stream chunkStream, CancellationToken ct = default)
Parameters
Returns
UploadFileAsync(Stream, string, long, string?, CancellationToken)
Validates a file, persists it through the configured provider, and raises validation and completion events.
Declaration
public Task<UploadResult> UploadFileAsync(Stream fileStream, string fileName, long fileSize, string? contentType = null, CancellationToken ct = default)
Parameters
Returns
ValidateFile(string, long, string?)
Validates a file against the configured size, extension, and MIME-type restrictions.
Returns null when the file is valid; otherwise returns a human-readable error message.
Declaration
public string? ValidateFile(string fileName, long fileSize, string? contentType = null)
Parameters
Returns
Implements