Table of Contents

Class DataStreamer<T>

Namespace
MongoDB.Entities
Assembly
MongoDB.Entities.dll

Provides the interface for uploading and downloading data chunks for file entities.

public class DataStreamer<T> where T : FileEntity<T>, new()

Type Parameters

T
Inheritance
DataStreamer<T>
Inherited Members

Methods

DeleteBinaryChunks(IClientSessionHandle?, CancellationToken)

Deletes only the binary chunks stored in the database for this file entity.

public Task DeleteBinaryChunks(IClientSessionHandle? session = null, CancellationToken cancellation = default)

Parameters

session IClientSessionHandle

An optional session if using within a transaction

cancellation CancellationToken

An optional cancellation token.

Returns

Task

DownloadAsync(Stream, int, CancellationToken, IClientSessionHandle?)

Download binary data for this file entity from mongodb in chunks into a given stream.

public Task DownloadAsync(Stream stream, int batchSize = 1, CancellationToken cancellation = default, IClientSessionHandle? session = null)

Parameters

stream Stream

The output stream to write the data

batchSize int

The number of chunks you want returned at once

cancellation CancellationToken

An optional cancellation token.

session IClientSessionHandle

An optional session if using within a transaction

Returns

Task

DownloadWithTimeoutAsync(Stream, int, int, IClientSessionHandle?)

Download binary data for this file entity from mongodb in chunks into a given stream with a timeout period.

public Task DownloadWithTimeoutAsync(Stream stream, int timeOutSeconds, int batchSize = 1, IClientSessionHandle? session = null)

Parameters

stream Stream

The output stream to write the data

timeOutSeconds int

The maximum number of seconds allowed for the operation to complete

batchSize int
session IClientSessionHandle

Returns

Task

UploadAsync(Stream, int, CancellationToken, IClientSessionHandle?)

Upload binary data for this file entity into mongodb in chunks from a given stream.

TIP: Make sure to save the entity before calling this method.

public Task UploadAsync(Stream stream, int chunkSizeKb = 256, CancellationToken cancellation = default, IClientSessionHandle? session = null)

Parameters

stream Stream

The input stream to read the data from

chunkSizeKb int

The 'average' size of one chunk in KiloBytes

cancellation CancellationToken

An optional cancellation token.

session IClientSessionHandle

An optional session if using within a transaction

Returns

Task

UploadWithTimeoutAsync(Stream, int, int, IClientSessionHandle?)

Upload binary data for this file entity into mongodb in chunks from a given stream with a timeout period.

public Task UploadWithTimeoutAsync(Stream stream, int timeOutSeconds, int chunkSizeKb = 256, IClientSessionHandle? session = null)

Parameters

stream Stream

The input stream to read the data from

timeOutSeconds int

The maximum number of seconds allowed for the operation to complete

chunkSizeKb int

The 'average' size of one chunk in KiloBytes

session IClientSessionHandle

An optional session if using within a transaction

Returns

Task