mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 21:41:36 +00:00
Enhance FileAttachment struct with validation checks for forbidden file types
This commit is contained in:
parent
d98c0afc4f
commit
2a4770eef3
@ -8,10 +8,20 @@ namespace AIStudio.Chat;
|
|||||||
public readonly record struct FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes)
|
public readonly record struct FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes)
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the file still exists on the file system.`
|
/// Gets a value indicating whether the file still exists on the file system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Exists => File.Exists(this.FilePath);
|
public bool Exists => File.Exists(this.FilePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the file type is forbidden and should not be attached.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsForbidden => this.Type == FileAttachmentType.FORBIDDEN;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the file type is valid and allowed to be attached.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsValid => this.Type != FileAttachmentType.FORBIDDEN;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a FileAttachment from a file path by automatically determining the type,
|
/// Creates a FileAttachment from a file path by automatically determining the type,
|
||||||
/// extracting the filename, and reading the file size.
|
/// extracting the filename, and reading the file size.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user