CoreUpload
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, string?, CancellationToken)

    Finalizes a chunked upload, recording the sanitized folder-relative path supplied by folder uploads. The default implementation ignores the path.

    Declaration
    Task<UploadResult> CompleteChunkedUploadAsync(string uploadId, string fileName, int totalChunks, string? relativePath, CancellationToken ct = default)
    Parameters
    Type Name Description
    string uploadId
    string fileName
    int totalChunks
    string relativePath
    CancellationToken ct
    Returns
    Type Description
    Task<UploadResult>

    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

    FindByHashAsync(string, long, CancellationToken)

    Finds a stored upload matching the given server-computed SHA-256 (and size, when non-zero), for instant-upload dedupe. The default implementation returns null.

    Declaration
    Task<UploadedFileInfo?> FindByHashAsync(string sha256, long size, CancellationToken ct = default)
    Parameters
    Type Name Description
    string sha256
    long size
    CancellationToken ct
    Returns
    Type Description
    Task<UploadedFileInfo>

    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?, string?, CancellationToken)

    Uploads a single file stream, recording the sanitized folder-relative path supplied by folder uploads. The default implementation ignores the path so existing IUploadService implementations keep working.

    Declaration
    Task<UploadResult> UploadFileAsync(Stream fileStream, string fileName, long fileSize, string? contentType, string? relativePath, CancellationToken ct = default)
    Parameters
    Type Name Description
    Stream fileStream
    string fileName
    long fileSize
    string contentType
    string relativePath
    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
    In this article
    Back to top CoreUpload API ReferenceUploader family: AjaxUploader, CoreUpload, MultipleUpload, ASPUploader, and PHP File Uploader.