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
CreateFileReceiveDescriptorAsync(ParticipantId, string, MetadataResponse, Role?)
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
senderIdParticipantIddescriptorIdstringmetadataFileTransferModels.MetadataResponsesenderRoleRole
Returns
CreateFileSendDescriptorAsync(ParticipantId, string, Stream, string?, DateTimeOffset?, uint, params HashingFunction[])
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
senderIdParticipantIddescriptorIdstringstreamStreamfilenamestringexpiryDateTimeOffset?maxSupportedChunkSizeuintsupportedHashingFunctionsHashingFunction[]
Returns
GetMetadataAsync(Location, CancellationToken)
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
fileLocationLocationcancellationTokenCancellationToken
Returns
RequestTransferAsync(Location, uint, IFileTransferDescriptor, CancellationToken)
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
fileLocationLocationchunkSizeuintreceiveDescriptorIFileTransferDescriptorcancellationTokenCancellationToken