Class FileTransferService

Namespace
Datamine.MineTrustConnector.Service.Extensibility
Assembly
Datamine.MineTrustConnector.Service.Extensibility.dll

Service responsible for performing file upload and download operations to and from MineTrust during normal service execution.

public class FileTransferService
Inheritance
FileTransferService
Inherited Members

Constructors

FileTransferService(IServiceProvider, IScopedServiceProvider<MineTrustClient>, IScopedServiceProvider<MineTrustFolderCache>, IOptions<IFileTransferOptions>, ILogger<FileTransferService>)

Service responsible for performing file upload and download operations to and from MineTrust during normal service execution.

public FileTransferService(IServiceProvider serviceProvider, IScopedServiceProvider<MineTrustClient> clientFactory, IScopedServiceProvider<MineTrustFolderCache> cacheFactory, IOptions<IFileTransferOptions> options, ILogger<FileTransferService> logger)

Parameters

serviceProvider IServiceProvider
clientFactory IScopedServiceProvider<MineTrustClient>
cacheFactory IScopedServiceProvider<MineTrustFolderCache>
options IOptions<IFileTransferOptions>
logger ILogger<FileTransferService>

Methods

DownloadFile(PackageConfiguration, MineTrustConnection, string, int, bool, int?, IProgress<int>?, CancellationToken)

Performs the low-level download operation for the specified file.

protected virtual Task<bool> DownloadFile(PackageConfiguration packageConfiguration, MineTrustConnection connection, string localFileName, int fileId, bool throwIfDestinationExists, int? fileVersionId, IProgress<int>? progress, CancellationToken cancel)

Parameters

packageConfiguration PackageConfiguration

The package configuration.

connection MineTrustConnection

The connection.

localFileName string

Name of the local file.

fileId int

The file identifier.

throwIfDestinationExists bool

if set to true [throw if destination exists].

fileVersionId int?

The file version identifier.

progress IProgress<int>

The progress.

cancel CancellationToken

The cancel.

Returns

Task<bool>

A task returning the success result

Exceptions

InvalidOperationException

$"Destination file '{localFileName}' already exists

DownloadFromServer(PackageConfiguration, MineTrustConnection, string?, int, int?, bool, IProgress<int>?, CancellationToken)

Ensures that the specified file is downloaded locally from the MineTrust server.

public Task<bool> DownloadFromServer(PackageConfiguration packageConfiguration, MineTrustConnection connection, string? maybeRelativePath, int fileId, int? fileVersionId = null, bool throwIfLocalFileExists = false, IProgress<int>? progress = null, CancellationToken cancel = default)

Parameters

packageConfiguration PackageConfiguration

The package configuration.

connection MineTrustConnection

The connection.

maybeRelativePath string

The maybe relative path.

fileId int

The file identifier.

fileVersionId int?

The file version identifier.

throwIfLocalFileExists bool

if set to true [throw if local file exists].

progress IProgress<int>

The progress.

cancel CancellationToken

The cancel.

Returns

Task<bool>

A task returning the success result

Exceptions

ArgumentException

String cannot be null or empty - maybeRelativePath

ExceedsCompressionThreshold(string)

Returns whether or not the specified local file exceeds the compression threshold.

public bool ExceedsCompressionThreshold(string filePath)

Parameters

filePath string

The file path.

Returns

bool

True if the compression threshold was exceeded, otherwise false

UploadFile(PackageConfiguration, MineTrustConnection, string, int, int?, IProgress<int>?, CancellationToken)

Performs the low-level upload operation for the specified file.

protected virtual Task<int?> UploadFile(PackageConfiguration packageConfiguration, MineTrustConnection connection, string sourceFileName, int parentFolderId, int? existingFileId, IProgress<int>? progress, CancellationToken cancel)

Parameters

packageConfiguration PackageConfiguration

The package configuration.

connection MineTrustConnection

The connection.

sourceFileName string

Name of the source file.

parentFolderId int

The parent folder.

existingFileId int?

The existing file identifier.

progress IProgress<int>

The progress.

cancel CancellationToken

The cancel.

Returns

Task<int?>

A task returning the ID of the created file, or null if no file was uploaded

UploadFromDisk(PackageConfiguration, MineTrustConnection, string?, int?, bool, IProgress<int>?, CancellationToken)

Ensures that the specified file is uploaded to MineTrust from the local copy.

public Task<int?> UploadFromDisk(PackageConfiguration packageConfiguration, MineTrustConnection connection, string? maybeRelativePath, int? existingFileId = null, bool checkOutDestination = false, IProgress<int>? progress = null, CancellationToken cancel = default)

Parameters

packageConfiguration PackageConfiguration

The package configuration.

connection MineTrustConnection

The connection.

maybeRelativePath string

The maybe relative path.

existingFileId int?

The existing file identifier.

checkOutDestination bool

if set to true [check out destination].

progress IProgress<int>

The progress.

cancel CancellationToken

The cancel.

Returns

Task<int?>

A task returning the success result

Exceptions

ArgumentException

String cannot be null or empty, nameof(maybeRelativePath)

Exception

$"Must supply an existing file ID when '{nameof(checkOutDestination)}' is set to 'true'