private static async Task Download( ITransferClient client, AutoDeleteDirectory directory, TransferContext context, IList <TransferPath> localSourcePaths, string uploadTargetPath, SampleRunner sampleRunner, CancellationToken token) { // Create a job-based download transfer request. Console2.WriteStartHeader("Transfer - Download"); string downloadTargetPath = directory.Path; TransferRequest downloadJobRequest = TransferRequest.ForDownloadJob(downloadTargetPath, context); downloadJobRequest.Application = "Github Sample"; downloadJobRequest.Name = "Download Sample"; Console2.WriteLine("Download started."); // Create a transfer job to download the sample dataset to the target local path. using (ITransferJob job = await client.CreateJobAsync(downloadJobRequest, token).ConfigureAwait(false)) { IEnumerable <TransferPath> remotePaths = localSourcePaths.Select( localPath => new TransferPath { SourcePath = uploadTargetPath + "\\" + Path.GetFileName(localPath.SourcePath), PathAttributes = TransferPathAttributes.File, TargetPath = downloadTargetPath }); await job.AddPathsAsync(remotePaths, token).ConfigureAwait(false); await sampleRunner.ChangeDataRateAsync(job, token).ConfigureAwait(false); // Await completion of the job. ITransferResult result = await job.CompleteAsync(token).ConfigureAwait(false); Console2.WriteLine("Download completed."); sampleRunner.DisplayTransferResult(result); Console2.WriteEndHeader(); } }
private static async Task DemoTransferAsync(IRelativityTransferHost host, CancellationToken token, SampleRunner sampleRunner) { // Search for the first logical file share. const int LogicalFileShareNumber = 1; RelativityFileShare fileShare = await sampleRunner.GetFileShareAsync(host, LogicalFileShareNumber, token).ConfigureAwait(false); // Assigning the file share bypasses auto-configuration that will normally use the default workspace repository. sampleRunner.AssignFileshare(fileShare); // Prepare transfer setup common for upload and download. IList <TransferPath> localSourcePaths = await sampleRunner.SearchLocalSourcePathsAsync(token).ConfigureAwait(false); string uploadTargetPath = sampleRunner.GetUniqueRemoteTargetPath(fileShare); TransferContext context = sampleRunner.CreateTransferContext(); using (ITransferClient client = await sampleRunner.CreateClientAsync(host, token).ConfigureAwait(false)) using (AutoDeleteDirectory directory = new AutoDeleteDirectory()) { await Upload(client, context, localSourcePaths, uploadTargetPath, sampleRunner, token); await Download(client, directory, context, localSourcePaths, uploadTargetPath, sampleRunner, token); } }