using Microsoft.AspNetCore.Http;

namespace PowderCoating.Application.Interfaces;

public interface IFileService
{
    /// <summary>
    /// Saves an uploaded file to the specified subfolder
    /// </summary>
    /// <param name="file">The file to save</param>
    /// <param name="subfolder">Subfolder within uploads directory (e.g., "equipment-manuals")</param>
    /// <param name="allowedExtensions">Array of allowed file extensions (e.g., [".pdf", ".docx"])</param>
    /// <param name="maxFileSize">Maximum file size in bytes</param>
    /// <returns>Tuple containing success status, file path (relative to wwwroot), and error message if any</returns>
    Task<(bool Success, string FilePath, string ErrorMessage)> SaveFileAsync(
        IFormFile file,
        string subfolder,
        string[] allowedExtensions,
        long maxFileSize);

    /// <summary>
    /// Deletes a file from the file system
    /// </summary>
    /// <param name="filePath">Relative path to the file (e.g., "uploads/equipment-manuals/file.pdf")</param>
    /// <returns>Tuple containing success status and error message if any</returns>
    Task<(bool Success, string ErrorMessage)> DeleteFileAsync(string filePath);

    /// <summary>
    /// Retrieves a file from the file system
    /// </summary>
    /// <param name="filePath">Relative path to the file</param>
    /// <returns>Tuple containing success status, file content, content type, and error message if any</returns>
    Task<(bool Success, byte[] FileContent, string ContentType, string ErrorMessage)> GetFileAsync(string filePath);

    /// <summary>
    /// Checks if a file exists
    /// </summary>
    /// <param name="filePath">Relative path to the file</param>
    /// <returns>True if file exists, false otherwise</returns>
    bool FileExists(string filePath);

    /// <summary>
    /// Gets the MIME content type for a file based on its extension
    /// </summary>
    /// <param name="fileName">The file name</param>
    /// <returns>MIME content type</returns>
    string GetContentType(string fileName);
}
