Interface IStorageService
- Namespace
- FoundationaLLM.Common.Interfaces
- Assembly
- FoundationaLLM.Common.dll
Provides services to interact with a storage.
public interface IStorageService
- Extension Methods
Properties
InstanceName
The optional instance name of the storage service.
string? InstanceName { get; set; }
Property Value
StorageAccountName
The name of the storage account.
string? StorageAccountName { get; }
Property Value
StorageContainerName
The name of the storage container.
string? StorageContainerName { get; }
Property Value
Methods
DeleteFileAsync(string, string, CancellationToken)
Deletes a file from storage.
Task DeleteFileAsync(string containerName, string filePath, CancellationToken cancellationToken = default)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to delete.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
FileExistsAsync(string, string, CancellationToken)
Checks if a file exists on the storage.
Task<bool> FileExistsAsync(string containerName, string filePath, CancellationToken cancellationToken)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to read.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
GetFilePathsAsync(string, string?, bool, CancellationToken)
Retrieves a list file paths in the specific directory.
Task<List<string>> GetFilePathsAsync(string containerName, string? directoryPath = null, bool recursive = true, CancellationToken cancellationToken = default)
Parameters
containerName
stringName of the container, file system or Workspace name.
directoryPath
stringDirectory to list file contents
recursive
boolRecurse through child folders
cancellationToken
CancellationTokenDetermines if a request should be cancelled.
Returns
GetMatchingFilePathsAsync(string, string, CancellationToken)
Retrieves a list of file paths that match a specific pattern.
Task<List<string>> GetMatchingFilePathsAsync(string containerName, string filePathPattern, CancellationToken cancellationToken = default)
Parameters
containerName
stringThe name of the container.
filePathPattern
stringThe file name pattern to match.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
ReadFile(string, string)
Reads the binary content of a specified file from the storage.
BinaryData ReadFile(string containerName, string filePath)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to read.
Returns
- BinaryData
The binary content of the file.
ReadFileAsync(string, string, CancellationToken)
Reads the binary content of a specified file from the storage.
Task<BinaryData> ReadFileAsync(string containerName, string filePath, CancellationToken cancellationToken)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to read.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
- Task<BinaryData>
The binary content of the file.
UpdateJSONFileAsync<T>(string, string, Func<T, T>, CancellationToken)
Updates a specified JSON file in the storage.
Task UpdateJSONFileAsync<T>(string containerName, string filePath, Func<T, T> objectTransformer, CancellationToken cancellationToken) where T : class
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to update.
objectTransformer
Func<T, T>A function that updates the object persisted in the JSON file.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
Type Parameters
T
The type of the object persisted in the JSON file.
WriteFileAsync(string, string, Stream, string?, CancellationToken)
Writes the binary content to a specified file from the storage.
Task WriteFileAsync(string containerName, string filePath, Stream fileContent, string? contentType, CancellationToken cancellationToken)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to read.
fileContent
StreamThe binary content written to the file.
contentType
stringAn optional content type.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.
Returns
WriteFileAsync(string, string, string, string?, CancellationToken)
Writes the string content to a specified file from the storage.
Task WriteFileAsync(string containerName, string filePath, string fileContent, string? contentType, CancellationToken cancellationToken)
Parameters
containerName
stringThe name of the container where the file is located.
filePath
stringThe path of the file to read.
fileContent
stringThe string content written to the file.
contentType
stringAn optional content type.
cancellationToken
CancellationTokenThe cancellation token that signals that operations should be cancelled.