Search Results for

Show / Hide Table of Contents

# Class FileSystemProvider

Default provider that stores uploads, metadata, and chunk sessions on the local file system.

##### Inheritance

object
FileSystemProvider

##### Implements

IUploaderProvider

##### Inherited Members

object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: CoreUpload.Providers

###### Assembly: CoreUpload.dll

##### Syntax

    public class FileSystemProvider : IUploaderProvider

### Constructors

#### FileSystemProvider(IOptions<CoreUploadOptions>, IWebHostEnvironment)

##### Declaration

    public FileSystemProvider(IOptions<CoreUploadOptions> options, IWebHostEnvironment env)

##### Parameters

Type | Name | Description
--- | --- | ---
IOptions<CoreUploadOptions> | options |
IWebHostEnvironment | env |

### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
string | fileName |
Stream | stream |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
string | uploadId |
string | fileName |
int | totalChunks |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<Guid> |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
string | destinationPath |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### DeleteAsync(Guid, CancellationToken)

Deletes a stored upload and its metadata. Missing files are ignored.

##### Declaration

    public Task DeleteAsync(Guid guid, CancellationToken ct = default)

##### Parameters

Type | Name | Description
--- | --- | ---
Guid | guid |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
string | uploadId |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<int> |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<string> |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<UploadedFileInfo> |

#### 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

Type | Name | Description
--- | --- | ---
string | uploadId |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<IReadOnlyDictionary<int, long>> |

#### 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

Type | Name | Description
--- | --- | ---
string | uploadId |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<long> |

#### MaintainAsync(CancellationToken)

Removes expired temporary uploads and stale chunk-session folders while preserving persisted uploads.

##### Declaration

    public Task MaintainAsync(CancellationToken ct = default)

##### Parameters

Type | Name | Description
--- | --- | ---
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
string | destinationPath |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<Stream> |

#### PersistAsync(Guid, CancellationToken)

Marks an upload as persisted so routine cleanup preserves it.

##### Declaration

    public Task PersistAsync(Guid guid, CancellationToken ct = default)

##### Parameters

Type | Name | Description
--- | --- | ---
Guid | guid |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
Guid | guid |
string | fileName |
Stream | stream |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

#### 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

Type | Name | Description
--- | --- | ---
string | uploadId |
int | chunkIndex |
Stream | stream |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task |

### Implements

IUploaderProvider