Table of Contents

Class FileUtils

Namespace
FoundationaLLM.Common.Utils
Assembly
FoundationaLLM.Common.dll

Contains methods for working with files.

public class FileUtils
Inheritance
FileUtils
Inherited Members
Extension Methods

Methods

GetFileContentType(string, BinaryData)

Determines the MIME content type of a file based on its name and binary content.

public static FileContentTypeResult GetFileContentType(string fileName, BinaryData fileContent)

Parameters

fileName string

The name of the file, including its extension. Used to infer the expected content type.

fileContent BinaryData

The binary data representing the contents of the file. Used to inspect and detect the actual content type.

Returns

FileContentTypeResult

A FileContentTypeResult containing the detected MIME type, a value indicating whether the type is supported, and whether the detected type matches the file extension.

Remarks

If the content type cannot be determined from the file's content, the method falls back to using the file extension. If neither can be determined, 'application/octet-stream' is returned as a default. The method attempts to resolve discrepancies between the file's content and its extension, favoring the extension for plain text files when appropriate.

GetMessageContentFileType(string?, string?)

Returns the type of the message content based on the file name.

public static string GetMessageContentFileType(string? fileName, string? fallbackValue)

Parameters

fileName string

The file name to evaluate.

fallbackValue string

If populated, defines the fallback type value if a mapping cannot be determined from the passed in file name. Otherwise, the default value is FilePath.

Returns

string