Class TusClient
A class to perform actions against a Tus enabled server.
Inherited Members
Namespace: Unity.Services.Ccd.Management
Assembly: Unity.Services.Ccd.Management.dll
Syntax
public class TusClient
Properties
AdditionalHeaders
A mutable dictionary of headers which will be included with all requests.
Declaration
public Dictionary<string, string> AdditionalHeaders { get; }
Property Value
Type | Description |
---|---|
Dictionary<string, string> |
HashingImplementation
Get or set the hashing algorithm implementation to be used for checksum calculation.
Declaration
public static HashingImplementation HashingImplementation { get; set; }
Property Value
Type | Description |
---|---|
HashingImplementation |
Proxy
Get or set the proxy to use when making requests.
Declaration
public IWebProxy Proxy { get; set; }
Property Value
Type | Description |
---|---|
IWebProxy |
Methods
CreateAsync(string, FileInfo, params (string key, string value)[])
Create a file at the Tus server.
Declaration
public Task<string> CreateAsync(string url, FileInfo fileInfo, params (string key, string value)[] metadata)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to the creation endpoint of the Tus server. |
FileInfo | fileInfo | The file which will be uploaded. |
(string key, string value)[] | metadata | Metadata to be stored alongside the file. |
Returns
Type | Description |
---|---|
Task<string> | The URL to the created file. |
Exceptions
Type | Condition |
---|---|
Exception | Throws if the response doesn't contain the required information. |
CreateAsync(string, long, params (string key, string value)[])
Create a file at the Tus server.
Declaration
public Task<string> CreateAsync(string url, long uploadLength, params (string key, string value)[] metadata)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to the creation endpoint of the Tus server. |
long | uploadLength | The byte size of the file which will be uploaded. |
(string key, string value)[] | metadata | Metadata to be stored alongside the file. |
Returns
Type | Description |
---|---|
Task<string> | The URL to the created file. |
Exceptions
Type | Condition |
---|---|
Exception | Throws if the response doesn't contain the required information. |
Delete(string)
Delete a file from the Tus server.
Declaration
public Task<bool> Delete(string url)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL of the file at the Tus server. |
Returns
Type | Description |
---|---|
Task<bool> | A bool indicating whether the file is deleted. |
DownloadAsync(string, CancellationToken)
Download a file from the Tus server.
Declaration
public TusOperation<TusHttpResponse> DownloadAsync(string url, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL of a file at the Tus server. |
CancellationToken | cancellationToken | A cancellation token to cancel the operation with. |
Returns
Type | Description |
---|---|
TusOperation<TusHttpResponse> | A TusOperation<T> which represents the download operation. |
GetServerInfo(string)
Get information about the Tus server.
Declaration
public Task<TusServerInfo> GetServerInfo(string url)
Parameters
Type | Name | Description |
---|---|---|
string | url | The URL of the Tus enabled endpoint. |
Returns
Type | Description |
---|---|
Task<TusServerInfo> | A TusServerInfo containing information about the Tus server. |
Exceptions
Type | Condition |
---|---|
Exception | Throws if request fails. |
HeadAsync(string)
Send a HEAD request to the Tus server.
Declaration
public Task<TusHttpResponse> HeadAsync(string url)
Parameters
Type | Name | Description |
---|---|---|
string | url | The endpoint to post the HEAD request to. |
Returns
Type | Description |
---|---|
Task<TusHttpResponse> | The response from the Tus server. |
UploadAsync(string, FileInfo, double, CancellationToken)
Upload a file to the Tus server.
Declaration
public TusOperation<List<TusHttpResponse>> UploadAsync(string url, FileInfo file, double chunkSize = 5, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to a previously created file. |
FileInfo | file | The file to upload. |
double | chunkSize | The size, in megabytes, of each file chunk when uploading. |
CancellationToken | cancellationToken | A cancellation token to cancel the operation with. |
Returns
Type | Description |
---|---|
TusOperation<List<TusHttpResponse>> | A TusOperation<T> which represents the upload operation. |
UploadAsync(string, Stream, double, CancellationToken)
Upload a file to the Tus server.
Declaration
public TusOperation<List<TusHttpResponse>> UploadAsync(string url, Stream fileStream, double chunkSize = 5, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to a previously created file. |
Stream | fileStream | A file stream of the file to upload. The stream will be closed automatically. |
double | chunkSize | The size, in megabytes, of each file chunk when uploading. |
CancellationToken | cancellationToken | A cancellation token to cancel the operation with. |
Returns
Type | Description |
---|---|
TusOperation<List<TusHttpResponse>> | A TusOperation<T> which represents the upload operation. |