Class DataStreamer<T>
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
sessionIClientSessionHandleAn optional session if using within a transaction
cancellationCancellationTokenAn optional cancellation token.
Returns
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
streamStreamThe output stream to write the data
batchSizeintThe number of chunks you want returned at once
cancellationCancellationTokenAn optional cancellation token.
sessionIClientSessionHandleAn optional session if using within a transaction
Returns
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
streamStreamThe output stream to write the data
timeOutSecondsintThe maximum number of seconds allowed for the operation to complete
batchSizeintsessionIClientSessionHandle
Returns
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
streamStreamThe input stream to read the data from
chunkSizeKbintThe 'average' size of one chunk in KiloBytes
cancellationCancellationTokenAn optional cancellation token.
sessionIClientSessionHandleAn optional session if using within a transaction
Returns
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
streamStreamThe input stream to read the data from
timeOutSecondsintThe maximum number of seconds allowed for the operation to complete
chunkSizeKbintThe 'average' size of one chunk in KiloBytes
sessionIClientSessionHandleAn optional session if using within a transaction