예제 #1
0
        public Task <Stream> OpenWriteAsync(string id, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);

            var result = new FixedStream(new MemoryStream(), null, fx =>
            {
                MemoryStream ms = (MemoryStream)fx.Parent;
                ms.Position     = 0;
                WriteAsync(id, ms, append, cancellationToken).Wait();
            });

            return(Task.FromResult <Stream>(result));
        }
예제 #2
0
        public Task <Stream> WriteAsync(string fullPath, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPath(fullPath);
            fullPath = StoragePath.Normalize(fullPath);

            var result = new FixedStream(new MemoryStream(), null, async fx =>
            {
                MemoryStream ms = (MemoryStream)fx.Parent;
                ms.Position     = 0;
                await WriteAsync(fullPath, ms, append, cancellationToken).ConfigureAwait(false);
            });

            return(Task.FromResult <Stream>(result));
        }
      public Task<Stream> OpenWriteAsync(string fullPath, bool append, CancellationToken cancellationToken)
      {
         GenericValidation.CheckBlobFullPath(fullPath);
         ValidateSecretName(fullPath);
         if (append) throw new ArgumentException("appending to secrets is not supported", nameof(append));

         var callbackStream = new FixedStream(new MemoryStream(), null, async fx =>
         {
            string value = Encoding.UTF8.GetString(((MemoryStream)fx.Parent).ToArray());

            await _vaultClient.SetSecretAsync(_vaultUri, fullPath, value).ConfigureAwait(false);
         });

         return Task.FromResult<Stream>(callbackStream);
         
      }
예제 #4
0
        public Task <Stream> OpenWriteAsync(string id, bool append, CancellationToken cancellationToken)
        {
            var callbackStream = new FixedStream(new MemoryStream(), null, fx =>
            {
                id = StoragePath.Normalize(id, false);
                ZipArchive archive = GetArchive(true);

                ZipArchiveEntry entry = archive.CreateEntry(id, CompressionLevel.Optimal);
                using (Stream dest = entry.Open())
                {
                    fx.Parent.Position = 0;
                    fx.Parent.CopyTo(dest);
                }
            });

            return(Task.FromResult <Stream>(callbackStream));
        }
        public Task <Stream> OpenWriteAsync(string id, bool append, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobId(id);
            ValidateSecretName(id);
            if (append)
            {
                throw new ArgumentException("appending to secrets is not supported", nameof(append));
            }

            var callbackStream = new FixedStream(new MemoryStream(), null, fx =>
            {
                string value = Encoding.UTF8.GetString(((MemoryStream)fx.Parent).ToArray());

                _vaultClient.SetSecretAsync(_vaultUri, id, value).Wait();
            });

            return(Task.FromResult <Stream>(callbackStream));
        }
예제 #6
0
        /// <summary>
        /// S3 doesnt support this natively and will cache everything in MemoryStream until disposed.
        /// </summary>
        public Task <Stream> OpenWriteAsync(string id, bool append, CancellationToken cancellationToken)
        {
            if (append)
            {
                throw new NotSupportedException();
            }
            GenericValidation.CheckBlobId(id);
            id = StoragePath.Normalize(id, false);

            var callbackStream = new FixedStream(new MemoryStream(), null, fx =>
            {
                var ms      = (MemoryStream)fx.Parent;
                ms.Position = 0;

                _fileTransferUtility.UploadAsync(ms, _bucketName, id, cancellationToken).Wait();
            });

            return(Task.FromResult <Stream>(callbackStream));
        }
예제 #7
0
        /// <summary>
        /// S3 doesnt support this natively and will cache everything in MemoryStream until disposed.
        /// </summary>
        public Task <Stream> OpenWriteAsync(string fullPath, bool append = false, CancellationToken cancellationToken = default)
        {
            if (append)
            {
                throw new NotSupportedException();
            }
            GenericValidation.CheckBlobFullPath(fullPath);
            fullPath = StoragePath.Normalize(fullPath, false);

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

            var callbackStream = new FixedStream(new MemoryStream(), null, async(fx) =>
            {
                var ms      = (MemoryStream)fx.Parent;
                ms.Position = 0;

                await _fileTransferUtility.UploadAsync(ms, _bucketName, fullPath, cancellationToken).ConfigureAwait(false);
            });

            return(Task.FromResult <Stream>(callbackStream));
        }