consolidate Service interface and implementation classes

This commit is contained in:
sbwalker
2025-08-11 16:53:32 -04:00
parent b3f6194fda
commit 64b8b5d3c8
70 changed files with 1763 additions and 1996 deletions

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@ -10,6 +9,103 @@ using Oqtane.Shared;
namespace Oqtane.Services
{
/// <summary>
/// Service to get / create / upload / download files.
/// </summary>
public interface IFileService
{
/// <summary>
/// Get all <see cref="File"/>s in the specified Folder
/// </summary>
/// <param name="folderId">The folder ID</param>
/// <returns></returns>
Task<List<File>> GetFilesAsync(int folderId);
/// <summary>
/// Get all <see cref="File"/>s in the specified folder.
/// </summary>
/// <param name="folder">
/// The folder path relative to where the files are stored.
/// TODO: todoc verify exactly from where the folder path must start
/// </param>
/// <returns></returns>
Task<List<File>> GetFilesAsync(string folder);
/// <summary>
/// Get one <see cref="File"/>
/// </summary>
/// <param name="fileId"></param>
/// <returns></returns>
Task<File> GetFileAsync(int fileId);
/// <summary>
/// Get a <see cref="File"/> based on the <see cref="Folder"/> and file name.
/// </summary>
/// <param name="folderId">Reference to the <see cref="Folder"/></param>
/// <param name="name">name of the file
/// </param>
/// <returns></returns>
Task<File> GetFileAsync(int folderId, string name);
/// <summary>
/// Add / store a <see cref="File"/> record.
/// This does not contain the file contents.
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
Task<File> AddFileAsync(File file);
/// <summary>
/// Update a <see cref="File"/> record.
/// Use this for rename a file or change some attributes.
/// This does not contain the file contents.
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
Task<File> UpdateFileAsync(File file);
/// <summary>
/// Delete a <see cref="File"/>
/// </summary>
/// <param name="fileId"></param>
/// <returns></returns>
Task DeleteFileAsync(int fileId);
/// <summary>
/// Upload a file from a URL to a <see cref="Folder"/>
/// </summary>
/// <param name="url"></param>
/// <param name="folderId"></param>
/// <param name="name"></param>
/// <returns></returns>
Task<File> UploadFileAsync(string url, int folderId, string name);
/// <summary>
/// Get / download a file (the body).
/// </summary>
/// <param name="fileId">Reference to a <see cref="File"/></param>
/// <returns>The bytes of the file</returns>
Task<byte[]> DownloadFileAsync(int fileId);
/// <summary>
/// Retrieve a list of files from a <see cref="Site"/> and <see cref="Folder"/>
/// </summary>
/// <param name="siteId">Reference to the <see cref="Site"/></param>
/// <param name="folderPath">Path of the folder
/// TODO: todoc verify exactly from where the folder path must start
/// </param>
/// <returns></returns>
Task<List<File>> GetFilesAsync(int siteId, string folderPath);
/// <summary>
/// Unzips the contents of a zip file
/// </summary>
/// <param name="fileId">Reference to the <see cref="File"/></param>
/// </param>
/// <returns></returns>
Task UnzipFileAsync(int fileId);
}
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
public class FileService : ServiceBase, IFileService
{