Table of Contents

Class FileTransferClient

Namespace
SmarterLink.Clients.Files
Assembly
SmarterLink.Clients.dll

Provides file transfer operations over MQTT using the SmarterLink file transfer protocol. Obtain an instance via SmarterLink.Bootstrapping.SmarterLinkBootstrapper.GetFileTransferClient or by injecting it through DI after calling AddSmarterLinkClients.

public sealed class FileTransferClient
Inheritance
FileTransferClient
Inherited Members

Methods

Creates and activates a receive descriptor in preparation for an incoming file transfer. Pass the returned descriptor to RequestTransferAsync(Location, uint, IFileTransferDescriptor, CancellationToken) to initiate the transfer.

public Task<IFileReceiverDescriptor> CreateFileReceiveDescriptorAsync(ParticipantId senderId, string descriptorId, FileTransferModels.MetadataResponse metadata, Role? senderRole = null)

Parameters

senderId ParticipantId
descriptorId string
metadata FileTransferModels.MetadataResponse
senderRole Role

Returns

Task<IFileReceiverDescriptor>

Creates and activates a send descriptor, making the provided stream available for transfer to receivers. The returned descriptor must be disposed when the file is no longer being served.

public Task<IFileTransferDescriptor> CreateFileSendDescriptorAsync(ParticipantId senderId, string descriptorId, Stream stream, string? filename = null, DateTimeOffset? expiry = null, uint maxSupportedChunkSize = 65536, params HashingFunction[] supportedHashingFunctions)

Parameters

senderId ParticipantId
descriptorId string
stream Stream
filename string
expiry DateTimeOffset?
maxSupportedChunkSize uint
supportedHashingFunctions HashingFunction[]

Returns

Task<IFileTransferDescriptor>

Requests metadata for the file at the given smarterlink:// location. Returns null if the sender does not respond before the cancellation token fires.

public Task<FileTransferModels.MetadataResponse?> GetMetadataAsync(Location fileLocation, CancellationToken cancellationToken = default)

Parameters

fileLocation Location
cancellationToken CancellationToken

Returns

Task<FileTransferModels.MetadataResponse>

Requests a file transfer from the sender at the given smarterlink:// location. Returns true if the sender accepted; false if rejected.

public Task<bool> RequestTransferAsync(Location fileLocation, uint chunkSize, IFileTransferDescriptor receiveDescriptor, CancellationToken cancellationToken = default)

Parameters

fileLocation Location
chunkSize uint
receiveDescriptor IFileTransferDescriptor
cancellationToken CancellationToken

Returns

Task<bool>