public AmazonViewModel()
 {
     ResizeSettings = new ResizeSettings
     {
         Settings = new List<ResizeSetting>()
     };
 }
        public ActionResult Index(HttpPostedFileBase file)
        {
            var imageBytes = ReadFully(file.InputStream);
            var s3Client = new S3Client();
            var resizeSettings = new ResizeSettings
            {
                Settings = new List<ResizeSetting>
                {
                    new ResizeSetting
                    {
                        Name = "Large",
                        Width = 700,
                        ImageEncoding = ImageEncoding.Jpg90
                    },
                    new ResizeSetting
                    {
                        Name = "Small",
                        Width = 300,
                        ImageEncoding = ImageEncoding.Jpg90
                    },
                    new ResizeSetting
                    {
                        Name = "Thumb",
                        Width = 100,
                        Height = 100,
                        ImageEncoding = ImageEncoding.Jpg
                    }
                }
            };

            Parallel.ForEach(resizeSettings.Settings, resizeSetting =>
            {
                var imageResizer = new ImageResizer(imageBytes);
            
                string fileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + resizeSetting.Name + ".jpg";
                var resizedImage = resizeSetting.Height > 0
                    ? imageResizer.Resize(resizeSetting.Width, resizeSetting.Height, true, resizeSetting.ImageEncoding)
                    : imageResizer.Resize(resizeSetting.Width, resizeSetting.ImageEncoding);
                string result = s3Client.AddFile(fileName, new MemoryStream(resizedImage));
            });
            
            var vm = new AmazonViewModel
            {
                Filename = file.FileName,
                S3BaseUrl = Settings.Default.S3BaseUrl,
                CloudfrontBaseUrl = Settings.Default.CloudfrontBaseUrl,
                Bucket = Settings.Default.AWSPublicFilesBucket,
                ResizeSettings = resizeSettings
            };

            return View("Index", vm);
        }