Add File Type and Detectors and Mime Type tools and Refactor Grouping ...
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.IO;
|
||||
using xCommons.Models;
|
||||
using System.Threading;
|
||||
using xCommons.Constants;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace xCommons.Interfaces
|
||||
{
|
||||
public interface IXFileTypeDetector
|
||||
{
|
||||
/// <summary>
|
||||
/// Detect MIME Type based on File Name ...
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
string DetectFromExtension(string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Detect XFileExtensions based on File Name ...
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
XFileExtensions? DetectExtension(string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Detect Type based on File's Magic Byte ...
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> DetectFromMagicBytesAsync(
|
||||
Stream stream,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Complexity Detect Type ...
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="providedMimeType"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XFileTypeDetectionResult> DetectAsync(
|
||||
string fileName,
|
||||
string providedMimeType,
|
||||
Stream stream,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check a File Extension is Known or not ...
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
bool IsKnownExtension(string fileName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user