/// <summary>
        /// Streams into file
        /// </summary>
        public async Task WriteAsync(string id, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);
            GenericValidation.CheckSourceStream(sourceStream);

            id = StoragePath.Normalize(id, false);
            using (Stream dest = CreateStream(id, !append))
            {
                await sourceStream.CopyToAsync(dest);
            }
        }
示例#2
0
        public Task WriteAsync(string id, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);
            GenericValidation.CheckSourceStream(sourceStream);

            id = StoragePath.Normalize(id, false);
            using (Stream dest = CreateStream(id, !append))
            {
                sourceStream.CopyTo(dest);
            }

            return(Task.FromResult(true));
        }
        public async Task WriteAsync(string id, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);
            ValidateSecretName(id);
            GenericValidation.CheckSourceStream(sourceStream);
            if (append)
            {
                throw new ArgumentException("appending to secrets is not supported", nameof(append));
            }

            string value = Encoding.UTF8.GetString(sourceStream.ToByteArray());

            await _vaultClient.SetSecretAsync(_vaultUri, id, value);
        }
示例#4
0
        public async Task WriteAsync(string id, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            if (append)
            {
                throw new NotSupportedException();
            }

            GenericValidation.CheckBlobId(id);
            GenericValidation.CheckSourceStream(sourceStream);

            //http://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html

            id = StoragePath.Normalize(id, false);
            await _fileTransferUtility.UploadAsync(sourceStream, _bucketName, id, cancellationToken);
        }
        public async Task WriteAsync(string id, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);
            GenericValidation.CheckSourceStream(sourceStream);

            if (append)
            {
                CloudAppendBlob cab = _blobContainer.GetAppendBlobReference(StoragePath.Normalize(id, false));
                if (!(await cab.ExistsAsync()))
                {
                    await cab.CreateOrReplaceAsync();
                }

                await cab.AppendFromStreamAsync(sourceStream);
            }
            else
            {
                CloudBlockBlob blob = _blobContainer.GetBlockBlobReference(StoragePath.Normalize(id, false));

                await blob.UploadFromStreamAsync(sourceStream);
            }
        }
        public async Task WriteAsync(string fullPath, Stream sourceStream, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckSourceStream(sourceStream);

            (CloudBlobContainer container, string path) = await GetPartsAsync(fullPath).ConfigureAwait(false);

            if (append)
            {
                CloudAppendBlob cab = container.GetAppendBlobReference(StoragePath.Normalize(path, false));
                if (!await cab.ExistsAsync())
                {
                    await cab.CreateOrReplaceAsync().ConfigureAwait(false);
                }

                await cab.AppendFromStreamAsync(sourceStream).ConfigureAwait(false);
            }
            else
            {
                CloudBlockBlob cloudBlob = container.GetBlockBlobReference(StoragePath.Normalize(path, false));

                await cloudBlob.UploadFromStreamAsync(sourceStream).ConfigureAwait(false);
            }
        }