Search Results for

Show / Hide Table of Contents

# Interface IUploadService

Defines the high-level upload operations used by CoreUpload endpoints and integrations. Implementations coordinate validation, storage, chunk assembly, retrieval, and lifecycle operations.

###### Namespace: CoreUpload.Services

###### Assembly: CoreUpload.dll

##### Syntax

    public interface IUploadService

### Methods

#### CompleteChunkedUploadAsync(string, string, int, CancellationToken)

Finalizes a chunked upload by assembling the stored chunks into a saved file.

##### Declaration

    Task<UploadResult> CompleteChunkedUploadAsync(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<UploadResult> |

#### CopyFileAsync(Guid, string, CancellationToken)

Copies an uploaded file to another destination while keeping the original upload intact.

##### Declaration

    Task CopyFileAsync(Guid fileGuid, string destinationPath, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### DeleteFileAsync(Guid, CancellationToken)

Deletes a previously uploaded file and its metadata.

##### Declaration

    Task DeleteFileAsync(Guid fileGuid, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### GetChunkStatusAsync(string, CancellationToken)

Gets the chunk indexes (and stored byte sizes) the server currently holds for an upload session, so a resuming client can re-upload anything missing. Returns null when the storage provider cannot enumerate chunks.

##### Declaration

    Task<IReadOnlyDictionary<int, long>?> GetChunkStatusAsync(string uploadId, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### GetFileInfoAsync(Guid, CancellationToken)

Gets metadata for a previously uploaded file. Returns null when the file is no longer available.

##### Declaration

    Task<UploadedFileInfo?> GetFileInfoAsync(Guid fileGuid, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### MoveFileAsync(Guid, string, CancellationToken)

Moves an uploaded file to a permanent destination path.

##### Declaration

    Task MoveFileAsync(Guid fileGuid, string destinationPath, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### OpenFileAsync(Guid, CancellationToken)

Opens a readable stream for an uploaded file. The caller is responsible for disposing the returned stream.

##### Declaration

    Task<Stream> OpenFileAsync(Guid fileGuid, CancellationToken ct = default)

##### Parameters

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

##### Returns

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

#### UploadChunkAsync(string, int, int, string, long, Stream, CancellationToken)

Stores one chunk for an upload session and updates progress tracking for that session.

##### Declaration

    Task<UploadResult> UploadChunkAsync(string uploadId, int chunkIndex, int totalChunks, string fileName, long totalFileSize, Stream chunkStream, CancellationToken ct = default)

##### Parameters

Type | Name | Description
--- | --- | ---
string | uploadId |
int | chunkIndex |
int | totalChunks |
string | fileName |
long | totalFileSize |
Stream | chunkStream |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<UploadResult> |

#### UploadFileAsync(Stream, string, long, string?, CancellationToken)

Uploads a single file stream and returns an UploadResult describing the saved file.

##### Declaration

    Task<UploadResult> UploadFileAsync(Stream fileStream, string fileName, long fileSize, string? contentType = null, CancellationToken ct = default)

##### Parameters

Type | Name | Description
--- | --- | ---
Stream | fileStream |
string | fileName |
long | fileSize |
string | contentType |
CancellationToken | ct |

##### Returns

Type | Description
--- | ---
Task<UploadResult> |

#### ValidateFile(string, long, string?)

Validates a file name, size, and optional MIME type against the current server rules. Returns null when the file is valid; otherwise returns an error message.

##### Declaration

    string? ValidateFile(string fileName, long fileSize, string? contentType = null)

##### Parameters

Type | Name | Description
--- | --- | ---
string | fileName |
long | fileSize |
string | contentType |

##### Returns

Type | Description
--- | ---
string |