<PackageReference Include="System.ClientModel" Version="1.15.0" />

System.ClientModel.BinaryContent

public abstract class BinaryContent : IDisposable
Represents binary content that can be sent to a cloud service as part of a PipelineRequest.
public string MediaType { get; protected set; }

Gets the media type of the content.

protected BinaryContent()

public static BinaryContent Create(BinaryData value)

Creates an instance of BinaryContent that contains the bytes held in the provided BinaryData instance.

public static BinaryContent Create<T>(T model, ModelReaderWriterOptions options = null) where T : IPersistableModel<T>

Creates an instance of BinaryContent that contains the bytes resulting from writing the value of the provided IPersistableModel<T>.

public static BinaryContent Create(Stream stream)

Creates an instance of BinaryContent that contains the bytes held in the provided Stream instance.

public static BinaryContent CreateJson<T>(T jsonSerializable, JsonSerializerOptions options = null)

Creates an instance of BinaryContent that contains the JSON representation of the provided object.

public static BinaryContent CreateJson<T>(T jsonSerializable, JsonTypeInfo<T> jsonTypeInfo)

Creates an instance of BinaryContent that contains the JSON representation of the provided object using the specified JSON type information.

public static BinaryContent CreateJson(string jsonString, bool validate = false)

Creates an instance of BinaryContent that contains the provided JSON string.

public abstract void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public abstract bool TryComputeLength(out long length)

Attempts to compute the length of the underlying body content, if available.

public abstract void WriteTo(Stream stream, CancellationToken cancellationToken = default)

Writes contents of this BinaryContent instance to the provided Stream.

public abstract Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default)

Writes contents of this BinaryContent instance to the provided Stream.