FileParameter Model
FileParameter Model documentation for .NET SDK
Represents a File passed to the API as a Parameter, allows using different backends for files.
Properties
| Name | Type | Description | Notes |
|---|---|---|---|
| Name | string | The filename | Default: "no_name_provided" |
| ContentType | string | The content type of the file | Default: "application/octet-stream" |
| Content | Stream | The content of the file |
Constructors
FileParameter(Stream content)
Construct a FileParameter just from the contents, will extract the filename from a filestream.
Parameters:
content(Stream): The file content
Example:
using var fileStream = File.OpenRead("document.pdf");
var fileParam = new FileParameter(fileStream);FileParameter(string filename, Stream content)
Construct a FileParameter from name and content.
Parameters:
filename(string): The filenamecontent(Stream): The file content
Example:
using var memoryStream = new MemoryStream(fileBytes);
var fileParam = new FileParameter("document.pdf", memoryStream);FileParameter(string filename, string contentType, Stream content)
Construct a FileParameter from name, content type, and content.
Parameters:
filename(string): The filenamecontentType(string): The content type of the filecontent(Stream): The file content
Example:
using var memoryStream = new MemoryStream(fileBytes);
var fileParam = new FileParameter("document.pdf", "application/pdf", memoryStream);Implicit Conversion
FileParameter supports implicit conversion from Stream for backwards compatibility:
using var fileStream = File.OpenRead("document.pdf");
FileParameter fileParam = fileStream; // Implicit conversionUsage
FileParameter is used when uploading files to the API, particularly for memory creation:
var api = new MemoriesApi(config);
using var fileStream = File.OpenRead("document.pdf");
var request = new MemoryCreationRequest
{
SpaceId = "space-uuid",
OriginalContent = new FileParameter("document.pdf", "application/pdf", fileStream)
};
var memory = await api.CreateMemoryAsync(request);