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
serviceProviderIServiceProviderclientFactoryIScopedServiceProvider<MineTrustClient>cacheFactoryIScopedServiceProvider<MineTrustFolderCache>optionsIOptions<IFileTransferOptions>loggerILogger<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
packageConfigurationPackageConfiguration-
The package configuration.
connectionMineTrustConnection-
The connection.
localFileNamestring-
Name of the local file.
fileIdint-
The file identifier.
throwIfDestinationExistsbool-
if set to
true[throw if destination exists]. fileVersionIdint?-
The file version identifier.
progressIProgress<int>-
The progress.
cancelCancellationToken-
The cancel.
Returns
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
packageConfigurationPackageConfiguration-
The package configuration.
connectionMineTrustConnection-
The connection.
maybeRelativePathstring-
The maybe relative path.
fileIdint-
The file identifier.
fileVersionIdint?-
The file version identifier.
throwIfLocalFileExistsbool-
if set to
true[throw if local file exists]. progressIProgress<int>-
The progress.
cancelCancellationToken-
The cancel.
Returns
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
filePathstring-
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
packageConfigurationPackageConfiguration-
The package configuration.
connectionMineTrustConnection-
The connection.
sourceFileNamestring-
Name of the source file.
parentFolderIdint-
The parent folder.
existingFileIdint?-
The existing file identifier.
progressIProgress<int>-
The progress.
cancelCancellationToken-
The cancel.
Returns
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
packageConfigurationPackageConfiguration-
The package configuration.
connectionMineTrustConnection-
The connection.
maybeRelativePathstring-
The maybe relative path.
existingFileIdint?-
The existing file identifier.
checkOutDestinationbool-
if set to
true[check out destination]. progressIProgress<int>-
The progress.
cancelCancellationToken-
The cancel.
Returns
Exceptions
- ArgumentException
-
String cannot be null or empty, nameof(maybeRelativePath)
- Exception
-
$"Must supply an existing file ID when '{nameof(checkOutDestination)}' is set to 'true'
