2024-11-10 16:57:24 -05:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2024-11-11 11:37:02 -05:00
|
|
|
|
namespace OpenHarbor.Storage.Abstractions;
|
2024-11-10 16:57:24 -05:00
|
|
|
|
|
|
|
|
|
public interface IStorageProvider
|
|
|
|
|
{
|
|
|
|
|
Task<List<IDirectoryOrFile>> GetListAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task<List<IDirectoryInfo>> GetDirectoriesAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task<List<IFileInfo>> GetFilesAsync(string path, string? pattern = null, SearchOption searchOption = SearchOption.TopDirectoryOnly, CancellationToken cancellationToken = default);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(string sourcePath, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(byte[] bytes, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(Stream stream, string path, bool overrideIfExists = true, CancellationToken cancellationToken = default);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(string sourcePath, string path, IWriteFileOptions options, CancellationToken cancellationToken);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(byte[] bytes, string path, IWriteFileOptions options, CancellationToken cancellationToken);
|
|
|
|
|
Task<IFileInfo> WriteFileAsync(Stream stream, string path, IWriteFileOptions options, CancellationToken cancellationToken);
|
|
|
|
|
Task<Stream> GetFileStreamAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task<byte[]> GetFileBytesAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task<string> GetFileContentAsync(string path, Encoding encoding, CancellationToken cancellationToken);
|
|
|
|
|
Task<bool> FileExistsAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task DeleteFileAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
Task DeleteDirectoryAsync(string path, bool force = false, CancellationToken cancellationToken = default);
|
|
|
|
|
Task<IDirectoryInfo> CreateDirectoryAsync(string path, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
|
|
bool IsFileNameAllowed(string fileName);
|
|
|
|
|
string SanitizeFileName(string key, string replacement);
|
|
|
|
|
}
|