src/Picturepark.SDK.V1/Partial/TransferClient.cs
/// <summary>Creates a transfer and waits for its completion.</summary>
/// <param name="transferName">The name of the transfer.</param>
/// <param name="files">The file names of the transfer.</param>
/// <param name="timeout">The timeout to wait for completion.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The transfer.</returns>
Creates a transfer and waits for its completion.
Creates a transfer and waits for its completion .
public async Task<CreateTransferResult> CreateAndWaitForCompletionAsync(string transferName, IEnumerable<FileLocations> files, TimeSpan? timeout = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var filteredFileNames = await FilterFilesByBlacklist(files).ConfigureAwait(false);
            var request = new CreateTransferRequest
            {
                Name = !string.IsNullOrEmpty(transferName) ? transferName : new Random().Next(1000, 9999).ToString(),
                TransferType = TransferType.FileUpload,
                Files = filteredFileNames.Select(f => new TransferUploadFile
                {
                    Identifier = f.Identifier,
                    FileName = f.UploadAs
                }).ToList()
            };
            var transfer = await CreateAsync(request, cancellationToken).ConfigureAwait(false);
            await _businessProcessClient.WaitForStatesAsync(transfer.BusinessProcessId, new[] { TransferState.Created.ToString() }, timeout, cancellationToken).ConfigureAwait(false);
            return new CreateTransferResult(transfer, request.Files);
        }
public async Task < CreateTransferResult > CreateAndWaitForCompletionAsync ( string transferName , IEnumerable < FileLocations > files , TimeSpan ? timeout = null , CancellationToken cancellationToken = default ( CancellationToken ) ) { var filteredFileNames = await FilterFilesByBlacklist ( files ) . ConfigureAwait ( false ) ; var request = new CreateTransferRequest { Name = ! string . IsNullOrEmpty ( transferName ) ? transferName : new Random ( ) . Next ( 1000 , 9999 ) . ToString ( ) , TransferType = TransferType . FileUpload , Files = filteredFileNames . Select ( f => new TransferUploadFile { Identifier = f . Identifier , FileName = f . UploadAs } ) . ToList ( ) } ; var transfer = await CreateAsync ( request , cancellationToken ) . ConfigureAwait ( false ) ; await _businessProcessClient . WaitForStatesAsync ( transfer . BusinessProcessId , new [ ] { TransferState . Created . ToString ( ) } , timeout , cancellationToken ) . ConfigureAwait ( false ) ; return new CreateTransferResult ( transfer , request . Files ) ; }
Creates a transfer and waits for its completion.
Creates a transfer and waits for its completion .
None
transferName
string
The name of the transfer.
The name of the transfer .
files
IEnumerable<FileLocations>
The file names of the transfer.
The file names of the transfer .
timeout
TimeSpan?
The timeout to wait for completion.
The timeout to wait for completion .
cancellationToken
CancellationToken
The cancellation token.
The cancellation token .