Interface IFileStorageService
Defines a file storage service that abstracts away the implementation details of interacting with different file storage providers.
Namespace: DataWeb.Storage
Assembly: DataWeb.Core.dll
Syntax
public interface IFileStorageService
Methods
CloneFileAsync(string, string, string, string, string, CancellationToken)
Clones a file from the source storage container to the target storage container in the specified storage service.
Declaration
Task<StorageResult> CloneFileAsync(string storageName, string sourceStorageFileName, string sourceStorageContainer, string targetStorageFileName, string targetStorageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage service where the file is stored. |
string | sourceStorageFileName | The name of the file to clone. |
string | sourceStorageContainer | The source storage container. |
string | targetStorageFileName | The name for the cloned file. |
string | targetStorageContainer | The target storage container. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageResult> | A StorageResult indicating the success or failure of the operation. |
DeleteFileAsync(string, string, string, CancellationToken)
Deletes a file from the specified storage service and container.
Declaration
Task<StorageResult> DeleteFileAsync(string storageName, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage service where the file is stored. |
string | storageFileName | The name of the file to delete. |
string | storageContainer | The storage container where the file is located. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageResult> | A StorageResult indicating the success or failure of the operation. |
DownloadFileStreamAsync(IFile, CancellationToken)
Downloads a stream for a file.
Declaration
Task<Stream> DownloadFileStreamAsync(IFile file, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IFile | file | The IFile to download. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Stream> | A stream for the file. |
DownloadFileStreamAsync(string, string, string, string, CancellationToken)
Downloads a stream for a file in the specified storage container.
Declaration
Task<Stream> DownloadFileStreamAsync(string storageName, string storageFileName, string storageContainer, string fileDomain = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the file storage provider. |
string | storageFileName | The name of the file in the storage container. |
string | storageContainer | The name of the storage container. |
string | fileDomain | The domain of the file. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Stream> | A stream for the file. |
FileExistsAsync(string, string, string, CancellationToken)
Checks if a file with the specified name exists in the specified storage container.
Declaration
Task<bool> FileExistsAsync(string storageName, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the file storage provider. |
string | storageFileName | The name of the file in the storage container. |
string | storageContainer | The name of the storage container. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A boolean indicating whether or not the file exists in the storage container. |
GetFilePropertiesAsync(string, string, string, CancellationToken)
Retrieves the properties of a file in the specified storage container.
Declaration
Task<StorageFileProperties> GetFilePropertiesAsync(string storageName, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the file storage provider. |
string | storageFileName | The name of the file in the storage container. |
string | storageContainer | The name of the storage container. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageFileProperties> | The properties of the file. |
GetFileStorageStores()
Returns a collection of all file storage stores associated with this file storage service.
Declaration
IEnumerable<IFileStorageStore> GetFileStorageStores()
Returns
Type | Description |
---|---|
IEnumerable<IFileStorageStore> | A collection of IFileStorageStore instances. |
GetFileStreamAsync(string, string, string, CancellationToken)
Retrieves a stream for a file in the specified storage container.
Declaration
Task<Stream> GetFileStreamAsync(string storageName, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the file storage provider. |
string | storageFileName | The name of the file in the storage container. |
string | storageContainer | The name of the storage container. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Stream> | A stream for the file. |
GetNewStorageFileName(string, string, string)
Generates a new unique file name for a file in the specified storage container.
Declaration
string GetNewStorageFileName(string storageName, string fileName, string storageContainer)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the file storage provider. |
string | fileName | The original file name. |
string | storageContainer | The name of the storage container. |
Returns
Type | Description |
---|---|
string | A new unique file name. |
MoveFileAsync(string, string, string, string, string, CancellationToken)
Moves a file from the source storage container to the target storage container in the specified storage service.
Declaration
Task<StorageResult> MoveFileAsync(string storageName, string sourceStorageFileName, string sourceStorageContainer, string targetStorageFileName, string targetStorageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage service where the file is stored. |
string | sourceStorageFileName | The name of the file to move. |
string | sourceStorageContainer | The source storage container. |
string | targetStorageFileName | The new name for the file after it is moved. |
string | targetStorageContainer | The target storage container. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageResult> | A StorageResult indicating the success or failure of the operation. |
UploadChunkStreamAsync(string, Stream, int, int, int, long, string, string, CancellationToken)
Uploads a chunk of a file stream to the specified storage provider.
Declaration
Task<StorageResult> UploadChunkStreamAsync(string storageName, Stream stream, int chunkNumber, int chunkSize, int chunkCount, long fileSize, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage provider. |
Stream | stream | The stream to upload. |
int | chunkNumber | The number of the chunk to upload. |
int | chunkSize | The size of each chunk. |
int | chunkCount | The total number of chunks. |
long | fileSize | |
string | storageFileName | The name of the file in the storage provider. |
string | storageContainer | The name of the storage container in the storage provider. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageResult> | The result of the upload operation. |
UploadFileStreamAsync(string, Stream, string, string, CancellationToken)
Uploads a stream to the specified storage provider.
Declaration
Task<StorageResult> UploadFileStreamAsync(string storageName, Stream stream, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage provider. |
Stream | stream | The stream to upload. |
string | storageFileName | The name of the file in the storage provider. |
string | storageContainer | The name of the storage container in the storage provider. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<StorageResult> | The result of the upload operation. |