Interface IRemoteFileStorage
A remote file storage with flat hierarchy (every file is nested under one container name) and GUID-based file access tokens.
public interface IRemoteFileStorage
Methods
Delete(string, Guid, string)
Attempts to delete a file from a remote file storage container that was uploaded using the Upload(string,System.Guid?,string) method.
Task<bool> Delete(string containerName, Guid fileAccessToken, string fileName)
Parameters
containerNamestringContainer name where the desired file is located. This could be some folder name such as "images", "videos", whatever...
fileAccessTokenGuidFile access token that uniquely identifies the folder in which to look for the file to delete. This is the value that was provided to the Upload(string,System.Guid?,string) function.
fileNamestringName of the file inside of the folder named fileAccessToken
Returns
Download(string, Guid, string)
Attempts a file download from a specific remote file storage container.
Task<Stream?> Download(string containerName, Guid fileAccessToken, string fileName)
Parameters
containerNamestringContainer name where the desired file is located. This could be some folder name such as "images", "videos", whatever...
fileAccessTokenGuidFile access token that uniquely identifies the folder in which to look for the file to download. This is the value that was provided to the Upload(string,System.Guid?,string) function.
fileNamestringName of the file inside of the folder named fileAccessToken.
Returns
GetFileSize(string, Guid, string)
Attempts to get a remote file's size in bytes.
Task<long?> GetFileSize(string containerName, Guid fileAccessToken, string fileName)
Parameters
containerNamestringContainer name where the desired file is located. This could be some folder name such as "images", "videos", whatever...
fileAccessTokenGuidFile access token that uniquely identifies the folder in which to look for the file to download. This is the value that was provided to the Upload(string,System.Guid?,string) function.
fileNamestringName of the file inside of the folder named fileAccessToken
Returns
Upload(string, Guid, string)
Opens an upload Stream that can be manually written to. Returns the writable Stream as well as the RemoteFileStorageUploadResponseDto instance containing the generated file access token and its full URI if the upload was successful.
Task<(Stream?, RemoteFileStorageUploadResponseDto?)> Upload(string containerName, Guid fileAccessToken, string fileName)
Parameters
containerNamestringDestination container. This could be some folder name such as "images", "videos", whatever...
fileAccessTokenGuidThe file guid. It will be used as the name of the folder.
fileNamestringThe destination file name.
Returns
- Task<(Stream, RemoteFileStorageUploadResponseDto?)>
The writable Stream as well as the RemoteFileStorageUploadResponseDto instance containing the generated file access token and its full URI if the upload was successful.
Upload(string, Stream, Guid, string)
Attempts a file upload to a specific remote file storage container. The file will be uploaded in a folder named fileAccessToken and it will be named fileName
Task<RemoteFileStorageUploadResponseDto?> Upload(string containerName, Stream stream, Guid fileAccessToken, string fileName)
Parameters
containerNamestringDestination container. This could be some folder name such as "images", "videos", whatever...
streamStreamThe file content to upload. The file to upload. Must be a readable Stream. Don't forget to dispose this afterwards!
fileAccessTokenGuidThe file guid. It will be used as the name of the folder.
fileNamestringThe destination file name.
Returns
- Task<RemoteFileStorageUploadResponseDto?>
nullif upload failed; RemoteFileStorageUploadResponseDto instance containing the generated file access token and its full URI if the upload was successful.