コード例 #1
0
        private async Task <HttpContent> StoreContentAsync(string rowKey, HttpContent originalContent, CancellationToken cancellationToken)
        {
            HttpContent storedContent = null;

            if (originalContent != null)
            {
                ICloudBlockBlob blob           = _blobContainer.GetBlockBlobReference(rowKey);
                Stream          originalStream = await originalContent.ReadAsStreamAsync();

                Stream destinationStream = await blob.OpenWriteAsync(cancellationToken);

                if (_useCompression)
                {
                    destinationStream = new GZipStream(destinationStream, CompressionLevel.Optimal);
                }

                using (destinationStream)
                {
                    await originalStream.CopyToAsync(destinationStream, BufferSize, cancellationToken);
                }

                storedContent = await GetStoredHttpContentAsync(rowKey, originalContent.Headers, _useCompression, cancellationToken);
            }

            return(storedContent);
        }
コード例 #2
0
        private async Task OrientAndSetMetadataAsync(MagickImage image, ICloudBlockBlob output, CancellationToken cancellationToken, ILogger logger, Stopwatch sw)
        {
            if (image.Orientation != OrientationType.Undefined && image.Orientation != OrientationType.TopLeft)
            {
                image.AutoOrient();
                using (var outputStream = await output.OpenWriteAsync(cancellationToken))
                {
                    image.Write(outputStream);
                    SetMetadata(image, output);
                    await Task.Factory.FromAsync(outputStream.BeginCommit(null, null), outputStream.EndCommit);
                }

                logger.Info("Orient: " + sw.ElapsedMilliseconds);
            }
            else
            {
                await SetAndSaveMetadata(output, image);
            }
        }