private object UploadThumbsOperation(params object[] args) { IPathGenerator _generator = new PathGenerator(); var fileName = Path.GetFileName(_filename); if (!String.IsNullOrWhiteSpace(txtUploadName.Text)) { fileName = txtUploadName.Text; } long quality = 80; if (!long.TryParse(ConfigurationManager.AppSettings["jpegQuality"], out quality)) { quality = 80; } var encoder = Encoder.Quality; var encParams = new EncoderParameters(1); var encParam = new EncoderParameter(encoder, quality); encParams.Param[0] = encParam; var jpegEncoder = GetEncoder(ImageFormat.Jpeg); var pathInBucket = _generator.GetPath(args[0] as ICategory, fileName); if (_thumbs.Any(t => t.IsChecked)) { var img = ThumbnailAggregator.Join(_thumbs.Where(t => t.IsChecked)); var stream = new MemoryStream(); img.Save(stream, jpegEncoder, encParams); var smallThumbsFilename = fileName + ".small.jpg"; _uploader.Upload(stream, _generator.GetPath(args[0] as ICategory, smallThumbsFilename)); } if (_mainThumb != null) { var stream = new MemoryStream(); var mainThumbFilename = fileName + ".main.jpg"; _mainThumb.Large.Save(stream, jpegEncoder, encParams); _uploader.Upload(stream, _generator.GetPath(args[0] as ICategory, mainThumbFilename)); } return(new object()); }
private object UploadThumbsOperation(params object[] args) { IPathGenerator _generator = new PathGenerator(); var fileName = Path.GetFileName(_filename); if (!String.IsNullOrWhiteSpace(txtUploadName.Text)) { fileName = txtUploadName.Text; } long quality = 80; if (!long.TryParse(ConfigurationManager.AppSettings["jpegQuality"], out quality)) { quality = 80; } var encoder = Encoder.Quality; var encParams = new EncoderParameters(1); var encParam = new EncoderParameter(encoder, quality); encParams.Param[0] = encParam; var jpegEncoder = GetEncoder(ImageFormat.Jpeg); var pathInBucket = _generator.GetPath(args[0] as ICategory, fileName); if (_thumbs.Any(t => t.IsChecked)) { var img = ThumbnailAggregator.Join(_thumbs.Where(t => t.IsChecked)); var stream = new MemoryStream(); img.Save(stream, jpegEncoder, encParams); var smallThumbsFilename = fileName + ".small.jpg"; _uploader.Upload(stream, _generator.GetPath(args[0] as ICategory, smallThumbsFilename)); } if (_mainThumb != null) { var stream = new MemoryStream(); var mainThumbFilename = fileName + ".main.jpg"; _mainThumb.Large.Save(stream, jpegEncoder, encParams); _uploader.Upload(stream, _generator.GetPath(args[0] as ICategory, mainThumbFilename)); } return new object() ; }