Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task AddOrReplaceFileToTransactionAsync(
            string filePath,
            string transactionId,
            string fileId,
            FileUploadOptions uploadOptions,
            CancellationToken cancellationToken = default)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            using (Stream fileStream = System.IO.File.Open(
                       filePath,
                       FileMode.Open,
                       FileAccess.Read,
                       FileShare.Delete | FileShare.Read))
            {
                await AddOrReplaceFileToTransactionAsync(
                    fileStream,
                    transactionId,
                    fileId,
                    uploadOptions,
                    cancellationToken)
                .ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task AddOrReplaceFileToTransactionAsync(
            Stream fileStream,
            string transactionId,
            string fileId,
            FileUploadOptions uploadOptions,
            CancellationToken cancellationToken = default)
        {
            if (fileStream == null)
            {
                throw new ArgumentNullException(nameof(fileStream));
            }

            if (transactionId == null)
            {
                throw new ArgumentNullException(nameof(transactionId));
            }

            if (string.IsNullOrWhiteSpace(transactionId))
            {
                throw new ArgumentException("Cannot be empty or contain only whitespaces.", nameof(transactionId));
            }

            if (fileId == null)
            {
                throw new ArgumentNullException(nameof(fileId));
            }

            if (string.IsNullOrWhiteSpace(fileId))
            {
                throw new ArgumentException("Cannot be empty or contain only whitespaces.", nameof(fileId));
            }

            if (uploadOptions == null)
            {
                uploadOptions = new FileUploadOptions();
            }

            var content = new StreamContent(fileStream)
                          .WithDigest(fileStream, uploadOptions.DigestOptions);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

            await client
            .PutAsync(
                "transaction".JoinPaths(transactionId, "file", fileId),
                content,
                cancellationToken)
            .EnsureSignhostSuccessStatusCodeAsync()
            .ConfigureAwait(false);
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public async Task AddOrReplaceFileToTransactionAsync(
     string filePath,
     string transactionId,
     string fileId,
     FileUploadOptions uploadOptions)
 => await AddOrReplaceFileToTransactionAsync(