Ejemplo n.º 1
0
 public async Task <BlobDto> SaveAsync([NotNull] string containerName, SaveBytesInput input)
 {
     //Request.EnableBuffering();
     //using (var reader = new StreamReader(Request.Body, System.Text.Encoding.UTF8))
     //{
     //    reader.BaseStream.Seek(0, SeekOrigin.Begin);  //大概是== Request.Body.Position = 0;的意思
     //    var readerStr = reader.ReadToEndAsync().Result;
     //}
     return(await _blobAppService.SaveAsync(containerName, input));
 }
Ejemplo n.º 2
0
        public async Task <BlobDto> SaveAsync([NotNull] string containerName, [NotNull] SaveBytesInput input)
        {
            using (var stream = new MemoryStream(input.Bytes))
            {
                var    blobContainer     = _blobContainerFactory.Create(containerName);
                string fileExtensionName = GetFileExtensionName(stream);
                var    blobName          = await GeneratorNameAsync(
                    containerName,
                    fileExtensionName
                    );

                await blobContainer.SaveAsync(blobName, stream, true);

                await CurrentUnitOfWork.SaveChangesAsync();

                //
                var blob = await _blobRepository.FindAsync(containerName, blobName);

                blob.BlobFileName = input.FileName;

                return(ObjectMapper.Map <Blob, BlobDto>(blob));
            }
        }