/*
* Copyright (c) 2023 Vaughn Nugent
*
* Library: CMNext
* Package: Content.Publishing.Blog.Admin
* File: IStorageFacade.cs
*
* CMNext is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* CMNext is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using VNLib.Net.Http;
namespace Content.Publishing.Blog.Admin.Storage
{
///
/// Represents an opaque storage interface that abstracts simple storage operations
/// ignorant of the underlying storage system.
///
internal interface IStorageFacade
{
///
/// Gets the full public file path for the given relative file path
///
/// The relative file path of the item to get the full path for
/// The full relative file path
string GetExternalFilePath(string filePath);
///
/// Deletes a file from the storage system asynchronously
///
/// The path to the file to delete
/// A token to cancel the operation
/// A task that represents and asynchronous work
Task DeleteFileAsync(string filePath, CancellationToken cancellation);
///
/// Writes a file from the stream to the given file location
///
/// The path to the file to write to
/// The file data to stream
/// The content type of the file to write
/// A token to cancel the operation
/// A task that represents and asynchronous work
Task SetFileAsync(string filePath, Stream data, ContentType ct, CancellationToken cancellation);
///
/// Reads a file from the storage system at the given path asynchronously
///
/// The file to read
/// The stream to write the file output to
/// A token to cancel the operation
/// The number of bytes read, -1 if the operation failed
Task ReadFileAsync(string filePath, Stream output, CancellationToken cancellation);
}
}