Exemplo n.º 1
0
 public static void DeleteImages(string postId)
 {
     BlobRepository.DeleteFolder(postId, BlobRepository.PostsContainer);
 }
Exemplo n.º 2
0
 public static void DeleteImages(string trackId)
 {
     BlobRepository.DeleteFolder(trackId, BlobRepository.TracksContainer);
 }
Exemplo n.º 3
0
        // images
        private static async Task <bool> ProcessImage(string postId, string imageUrl)
        {
            using (WebClient webClient = new WebClient())
            {
                byte[] data        = webClient.DownloadData(imageUrl);
                string contentType = webClient.ResponseHeaders["Content-Type"];

                // check correct content type
                if ("image/jpeg" != contentType)
                {
                    return(false);
                }

                /// generate mini
                using (MemoryStream input = new MemoryStream(data))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        Images.CropSquare(48, input, output);

                        using (output)
                        {
                            await BlobRepository.UploadFileAsync(BlobRepository.PostsContainer, output.ToArray(), postId + "/thumb_mini", contentType);
                        }
                    }
                }

                // generate thumb
                using (MemoryStream input = new MemoryStream(data))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        Images.CropSquare(150, input, output);

                        using (output)
                        {
                            await BlobRepository.UploadFileAsync(BlobRepository.PostsContainer, output.ToArray(), postId + "/thumb", contentType);
                        }
                    }
                }

                // hero
                using (MemoryStream input = new MemoryStream(data))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        Images.GenerateHero(400, input, output);

                        using (output)
                        {
                            await BlobRepository.UploadFileAsync(BlobRepository.PostsContainer, output.ToArray(), postId + "/hero", contentType);
                        }
                    }
                }

                // resized
                using (MemoryStream input = new MemoryStream(data))
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        Images.Resize(800, input, output);

                        using (output)
                        {
                            await BlobRepository.UploadFileAsync(BlobRepository.PostsContainer, output.ToArray(), postId + "/large", contentType);
                        }
                    }
                }

                return(true);
            }
        }