public void SaveAsciiArt(CloudStorageAccount account, AsciiArtResult result) { var blobClient = account.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(result.Container); var asciiBlob = container.GetBlobReference(result.BlobRef); var image = _repository.Get <ImageFile>(Guid.Parse(result.BlobRef)); var writable = image.MakeWritable <ImageFile>(); using (var stream = new MemoryStream()) { asciiBlob.DownloadToStream(stream); var asciiArt = Encoding.UTF8.GetString(stream.ToArray()); writable.AsciiArt = asciiArt; writable.Description = result.Description; writable.Tags = string.Join(",", result.Tags); _repository.Save(writable, SaveAction.Publish, AccessLevel.NoAccess); } }
public static async Task <CloudQueueMessage> Run( [QueueTrigger("to-ascii-conversion")] AsciiArtRequest request, [Blob("%input-container%/{BlobRef}", FileAccess.Read)] Stream inBlob, [Blob("%output-container%/{BlobRef}", FileAccess.Write)] Stream outBlob, TraceWriter log) { log.Info("(Fun3) Starting to convert image to ASCII art..."); var convertedImage = ConvertImageToAscii(inBlob, request.Width); await outBlob.WriteAsync(convertedImage, 0, convertedImage.Length); var result = new AsciiArtResult(request.BlobRef, ConfigurationManager.AppSettings["output-container"], request.Description, request.Tags); log.Info("(Fun3) Finished converting image."); return(result.AsQueueItem()); }