Class UploadedFile
Represents the complete file of a chunked upload, which the handler of the upload takes as a parameter.
Implements
Namespace: Singulink.Net.Http.Api.Service.Uploads
Assembly: Singulink.Net.Http.Api.Service.dll
Syntax
public class UploadedFile : IBindableFromHttpContext<UploadedFile>
Remarks
The file is removed once the handler finishes, unless the handler moved it with MoveToAsync(string, CancellationToken) or failed with a 503, which leaves the
file for the next run of the handler. A handler that moves the file and then fails with a 503 leaves no file for the next run, which then fails,
or, past UnstartedExpiry after the upload's creation, finds the upload expired, since without its file the upload
counts as one that received no chunk.
A handler that reads it with OpenReadStream() works with any IUploadStore, while FilePath is only available from
stores that keep the file in a file system, such as the directory store.
Constructors
| Name | Description |
|---|---|
| UploadedFile(string, string, long, string?, UploadContent) | Initializes a new instance of the UploadedFile class. |
Properties
| Name | Description |
|---|---|
| ContentType | Gets the content type of the file as the client sent it, or null if it sent none. |
| FileName | Gets the name of the file as the client sent it. |
| FilePath | Gets the path of a file that has the complete file, or null if the upload store keeps none, as for stores that keep uploads in an object store. With the directory store, the file is in the upload's directory. |
| Id | Gets the upload ID. |
| Length | Gets the length of the file in bytes, which is the length that the upload was created with. |
Methods
| Name | Description |
|---|---|
| MoveToAsync(string, CancellationToken) | Moves the file to a new file at the specified path, so that it is kept after the handler finishes. A store that keeps the file in a file system moves it, which copies nothing on the same volume, and other stores copy it there. |
| OpenReadStream() | Opens a read-only stream of the file. The stream of the directory store is seekable. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IBindableFromHttpContext<UploadedFile>.BindAsync(HttpContext, ParameterInfo) | Binds the uploaded file parameter of the handler of a chunked upload. |