Table of Contents

Interface IRemoteFileStorage

Namespace
GastroSky.Services.Files
Assembly
GastroSky.dll

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

containerName string

Container name where the desired file is located. This could be some folder name such as "images", "videos", whatever...

fileAccessToken Guid

File 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.

fileName string

Name of the file inside of the folder named fileAccessToken

Returns

Task<bool>

Whether the file was deleted successfully or not.

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

containerName string

Container name where the desired file is located. This could be some folder name such as "images", "videos", whatever...

fileAccessToken Guid

File 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.

fileName string

Name of the file inside of the folder named fileAccessToken.

Returns

Task<Stream>

The downloaded file stream(or null if the download failed/no such file was found).

GetFileSize(string, Guid, string)

Attempts to get a remote file's size in bytes.

Task<long?> GetFileSize(string containerName, Guid fileAccessToken, string fileName)

Parameters

containerName string

Container name where the desired file is located. This could be some folder name such as "images", "videos", whatever...

fileAccessToken Guid

File 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.

fileName string

Name of the file inside of the folder named fileAccessToken

Returns

Task<long?>

null if file not found or operation failed; file size in bytes otherwise.

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

containerName string

Destination container. This could be some folder name such as "images", "videos", whatever...

fileAccessToken Guid

The file guid. It will be used as the name of the folder.

fileName string

The 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

containerName string

Destination container. This could be some folder name such as "images", "videos", whatever...

stream Stream

The file content to upload. The file to upload. Must be a readable Stream. Don't forget to dispose this afterwards!

fileAccessToken Guid

The file guid. It will be used as the name of the folder.

fileName string

The destination file name.

Returns

Task<RemoteFileStorageUploadResponseDto?>

null if upload failed; RemoteFileStorageUploadResponseDto instance containing the generated file access token and its full URI if the upload was successful.