GoodMem
ReferenceClient SDKs.NET SDKModels

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

NameTypeDescriptionNotes
NamestringThe filenameDefault: "no_name_provided"
ContentTypestringThe content type of the fileDefault: "application/octet-stream"
ContentStreamThe 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 filename
  • content (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 filename
  • contentType (string): The content type of the file
  • content (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 conversion

Usage

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);

↑ Back to .NET SDK