AjaxUploader
Search Results for

    Show / Hide Table of Contents

    Class UploadService

    Default implementation of IUploadService built on top of an IUploaderProvider.

    Inheritance
    object
    UploadService
    Implements
    IUploadService
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: AjaxUploader.Services
    Assembly: AjaxUploader.dll
    Syntax
    public class UploadService : IUploadService

    Constructors

    UploadService()

    Initializes a new instance of the UploadService class using the current provider from ProviderFactory.

    Declaration
    public UploadService()

    UploadService(IUploaderProvider)

    Initializes a new instance of the UploadService class.

    Declaration
    public UploadService(IUploaderProvider provider)
    Parameters
    Type Name Description
    IUploaderProvider provider

    Methods

    CompleteChunkedUpload(string, string, int)

    Completes a chunked upload by assembling chunks and finalizing progress state. The returned result contains the final stored file GUID and size.

    Declaration
    public UploadResult CompleteChunkedUpload(string uploadId, string fileName, int totalChunks)
    Parameters
    Type Name Description
    string uploadId
    string fileName
    int totalChunks
    Returns
    Type Description
    UploadResult

    CompleteChunkedUpload(string, string, int, string)

    Completes a chunked upload, also recording the sanitized folder-relative path supplied by folder uploads (or null).

    Declaration
    public UploadResult CompleteChunkedUpload(string uploadId, string fileName, int totalChunks, string relativePath)
    Parameters
    Type Name Description
    string uploadId
    string fileName
    int totalChunks
    string relativePath
    Returns
    Type Description
    UploadResult

    CopyFile(Guid, string)

    Copies a stored uploaded file to a new destination path. This keeps the original stored upload intact.

    Declaration
    public void CopyFile(Guid fileGuid, string destinationPath)
    Parameters
    Type Name Description
    Guid fileGuid
    string destinationPath

    DeleteFile(Guid)

    Deletes a stored uploaded file.

    Declaration
    public void DeleteFile(Guid fileGuid)
    Parameters
    Type Name Description
    Guid fileGuid

    GetChunkStatus(string)

    Gets the chunk indexes and stored 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 (custom providers without a GetSavedChunks implementation).

    Declaration
    public Dictionary<int, long> GetChunkStatus(string uploadId)
    Parameters
    Type Name Description
    string uploadId
    Returns
    Type Description
    Dictionary<int, long>

    GetFileInfo(Guid)

    Gets metadata for a stored uploaded file. Returns null when the file no longer exists.

    Declaration
    public UploadedFileInfo GetFileInfo(Guid fileGuid)
    Parameters
    Type Name Description
    Guid fileGuid
    Returns
    Type Description
    UploadedFileInfo

    GetFilePath(Guid)

    Returns the stored file's full path for file-system-backed providers, or null otherwise (v4's GetTempFilePath contract).

    Declaration
    public string GetFilePath(Guid fileGuid)
    Parameters
    Type Name Description
    Guid fileGuid
    Returns
    Type Description
    string

    MoveFile(Guid, string)

    Moves a stored uploaded file to a new destination path. This is typically used when promoting a temporary upload into permanent storage.

    Declaration
    public void MoveFile(Guid fileGuid, string destinationPath)
    Parameters
    Type Name Description
    Guid fileGuid
    string destinationPath

    OpenFile(Guid)

    Opens a stored uploaded file for reading. Callers are responsible for disposing the returned stream.

    Declaration
    public Stream OpenFile(Guid fileGuid)
    Parameters
    Type Name Description
    Guid fileGuid
    Returns
    Type Description
    Stream

    UploadChunk(string, int, int, string, long, Stream)

    Saves one chunk of a chunked upload and updates progress state. Validation is performed on the first chunk before any data is persisted.

    Declaration
    public UploadResult UploadChunk(string uploadId, int chunkIndex, int totalChunks, string fileName, long totalFileSize, Stream chunkStream)
    Parameters
    Type Name Description
    string uploadId
    int chunkIndex
    int totalChunks
    string fileName
    long totalFileSize
    Stream chunkStream
    Returns
    Type Description
    UploadResult

    UploadFile(Stream, string, long, string)

    Uploads a complete file in one request. The file is validated first, then saved through the configured provider.

    Declaration
    public UploadResult UploadFile(Stream fileStream, string fileName, long fileSize, string contentType = null)
    Parameters
    Type Name Description
    Stream fileStream
    string fileName
    long fileSize
    string contentType
    Returns
    Type Description
    UploadResult

    UploadFile(Stream, string, long, string, string)

    Validates and saves a file, also recording the sanitized folder-relative path supplied by folder uploads (or null).

    Declaration
    public UploadResult UploadFile(Stream fileStream, string fileName, long fileSize, string contentType, string relativePath)
    Parameters
    Type Name Description
    Stream fileStream
    string fileName
    long fileSize
    string contentType
    string relativePath
    Returns
    Type Description
    UploadResult

    ValidateFile(string, long, string)

    Validates the file name, file size, and optional MIME type against current configuration rules. 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
    Type Name Description
    string fileName
    long fileSize
    string contentType
    Returns
    Type Description
    string

    Implements

    IUploadService
    In this article
    Back to top AjaxUploader API Reference