Class FileSystemProvider
Default provider that stores uploads, metadata, and chunk sessions on the local file system.
Inheritance
FileSystemProvider
Assembly: CoreUpload.dll
Syntax
public class FileSystemProvider : IUploaderProvider
Constructors
FileSystemProvider(IOptions<CoreUploadOptions>, IWebHostEnvironment)
Declaration
public FileSystemProvider(IOptions<CoreUploadOptions> options, IWebHostEnvironment env)
Parameters
Methods
AppendAsync(Guid, string, Stream, CancellationToken)
Appends to an existing uploaded file and refreshes the stored file size metadata.
Declaration
public Task AppendAsync(Guid guid, string fileName, Stream stream, CancellationToken ct = default)
Parameters
Returns
AssembleChunksAsync(string, string, int, CancellationToken)
Assembles the chunk files for an upload session into one stored upload and removes the temporary chunk folder afterward.
Declaration
public Task<Guid> AssembleChunksAsync(string uploadId, string fileName, int totalChunks, CancellationToken ct = default)
Parameters
Returns
CopyToAsync(Guid, string, CancellationToken)
Copies a stored upload to a destination path while keeping the original upload intact.
Declaration
public Task CopyToAsync(Guid guid, string destinationPath, CancellationToken ct = default)
Parameters
Returns
DeleteAsync(Guid, CancellationToken)
Deletes a stored upload and its metadata.
Missing files are ignored.
Declaration
public Task DeleteAsync(Guid guid, CancellationToken ct = default)
Parameters
Returns
GetCompletedChunksAsync(string, CancellationToken)
Gets the number of chunk files already stored for a chunked upload session.
Declaration
public Task<int> GetCompletedChunksAsync(string uploadId, CancellationToken ct = default)
Parameters
Returns
GetFilePathAsync(Guid, CancellationToken)
Gets the local file-system path for a stored upload.
Returns null when the file is missing.
Declaration
public Task<string?> GetFilePathAsync(Guid guid, CancellationToken ct = default)
Parameters
Returns
GetInfoAsync(Guid, CancellationToken)
Gets metadata for a stored upload.
Returns null when the metadata file does not exist.
Declaration
public Task<UploadedFileInfo?> GetInfoAsync(Guid guid, CancellationToken ct = default)
Parameters
Returns
GetSavedChunksAsync(string, CancellationToken)
Gets the chunk indexes and stored sizes for a chunked upload session by
enumerating the session's chunk_NNNNNN files. Returns an empty map
when the session folder does not exist.
Declaration
public Task<IReadOnlyDictionary<int, long>?> GetSavedChunksAsync(string uploadId, CancellationToken ct = default)
Parameters
Returns
GetUploadedLengthAsync(string, CancellationToken)
Gets the total number of bytes already stored for a chunked upload session.
Declaration
public Task<long> GetUploadedLengthAsync(string uploadId, CancellationToken ct = default)
Parameters
Returns
MaintainAsync(CancellationToken)
Removes expired temporary uploads and stale chunk-session folders while preserving persisted uploads.
Declaration
public Task MaintainAsync(CancellationToken ct = default)
Parameters
Returns
MoveToAsync(Guid, string, CancellationToken)
Moves a stored upload to a destination path and removes the original metadata file.
Declaration
public Task MoveToAsync(Guid guid, string destinationPath, CancellationToken ct = default)
Parameters
Returns
OpenReadAsync(Guid, CancellationToken)
Opens a readable stream for a stored upload.
The caller is responsible for disposing the returned stream.
Declaration
public Task<Stream> OpenReadAsync(Guid guid, CancellationToken ct = default)
Parameters
Returns
PersistAsync(Guid, CancellationToken)
Marks an upload as persisted so routine cleanup preserves it.
Declaration
public Task PersistAsync(Guid guid, CancellationToken ct = default)
Parameters
Returns
SaveAsync(Guid, string, Stream, CancellationToken)
Saves a new uploaded file and writes a matching metadata file.
Declaration
public Task SaveAsync(Guid guid, string fileName, Stream stream, CancellationToken ct = default)
Parameters
Returns
SaveChunkAsync(string, int, Stream, CancellationToken)
Saves a single chunk for an upload session under the provider's chunk folder.
Declaration
public Task SaveChunkAsync(string uploadId, int chunkIndex, Stream stream, CancellationToken ct = default)
Parameters
Returns
Implements