mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 20:01:37 +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)
|
||||
{
|
||||
/// <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>
|
||||
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>
|
||||
/// Creates a FileAttachment from a file path by automatically determining the type,
|
||||
/// extracting the filename, and reading the file size.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user