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 |

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

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

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

#### ValidateFile(string, long)

Validates the file name and file size 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)

##### Parameters

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

##### Returns

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

### Implements

IUploadService