private FileDownload CreateFileDownloadInternally(string actionId, long nodeId, Stream output, IFileDownloadCallback callback) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation CheckDownloadActionId(actionId); nodeId.MustPositive(nameof(nodeId)); output.CheckStreamCanWrite(nameof(output)); #endregion FileDownload download = null; Node nodeToDownload = GetNode(nodeId); // Validation will be done in "GetNode" if (nodeToDownload.IsEncrypted.GetValueOrDefault(false)) { UserKeyPair keyPair = _client.AccountImpl.GetAndCheckUserKeyPair(); download = new EncFileDownload(_client, actionId, nodeToDownload, output, keyPair.UserPrivateKey); } else { download = new FileDownload(_client, actionId, nodeToDownload, output); } _runningDownloads.Add(actionId, download); download.AddFileDownloadCallback(callback); download.AddFileDownloadCallback(this); return(download); }
public void StartDownloadFileAsync(string actionId, long nodeId, Stream output, IFileDownloadCallback callback) { FileDownload download = CreateFileDownloadInternally(actionId, nodeId, output, callback); download.RunAsync(); }