Table of Contents

Class BinaryFile

Namespace
GroupeIsa.Neos.Shared.IO
Assembly
GroupeIsa.Neos.Shared.dll

Represents a binary file.

public sealed class BinaryFile : ValueObject
Inheritance
BinaryFile
Inherited Members

Constructors

BinaryFile(byte[])

Initializes a new instance of the BinaryFile class.

public BinaryFile(byte[] content)

Parameters

content byte[]

Content.

BinaryFile(byte[], string?, IReadOnlyDictionary<string, object>?)

Initializes a new instance of the BinaryFile class.

public BinaryFile(byte[] content, string? mimeType, IReadOnlyDictionary<string, object>? metadata = null)

Parameters

content byte[]

Content.

mimeType string

Mime type.

metadata IReadOnlyDictionary<string, object>

Metadata.

BinaryFile(string?, byte[], string?, IReadOnlyDictionary<string, object>?)

Initializes a new instance of the BinaryFile class.

public BinaryFile(string? name, byte[] content, string? mimeType = null, IReadOnlyDictionary<string, object>? metadata = null)

Parameters

name string

Name.

content byte[]

Content.

mimeType string

Mime type.

metadata IReadOnlyDictionary<string, object>

Metadata.

Fields

OctetStreamMimeType

Represents the (default) MIME type for binary data streams.

public const string OctetStreamMimeType = "application/octet-stream"

Field Value

string

Remarks

This constant is commonly used to specify the MIME type for generic binary data when no specific format is applicable.

PdfMimeType

Represents the MIME type for PDF files.

public const string PdfMimeType = "application/pdf"

Field Value

string

Remarks

This constant can be used to specify or validate the MIME type for PDF documents in scenarios such as HTTP headers, file uploads, or content type checks.

Properties

Content

Gets the content.

public byte[] Content { get; init; }

Property Value

byte[]

Empty

Gets an empty binary file.

public static BinaryFile Empty { get; }

Property Value

BinaryFile

Metadata

Gets the file metadata.

public IReadOnlyDictionary<string, object> Metadata { get; init; }

Property Value

IReadOnlyDictionary<string, object>

MimeType

Gets the document mime type.

public string MimeType { get; }

Property Value

string

Name

Gets the file name with extension.

public string? Name { get; init; }

Property Value

string

Methods

GetEqualityComponents()

Gets equality components.

protected override IEnumerable<object?> GetEqualityComponents()

Returns

IEnumerable<object>

The components.

WithMetadata(string, object)

Adds a metadata to binary file.

public BinaryFile WithMetadata(string key, object value)

Parameters

key string

The metadata key.

value object

The metadata value.

Returns

BinaryFile

The new instance.

WithMimeType(string)

Sets the MIME type.

public BinaryFile WithMimeType(string mimeType)

Parameters

mimeType string

The MIME type.

Returns

BinaryFile

The same instance if MIME type is up to date or if previous MIME type is application/octet-stream, a new instance otherwise.

WithName(string?)

Sets the name.

public BinaryFile WithName(string? name)

Parameters

name string

The file name.

Returns

BinaryFile

The same instance if name is up to date, a new instance otherwise.