public ImageUploadResult PostImageToServer([FromBody] ProductImage productImage) { var cloudinary = GetCloudinaryAccountInfo(); var image = productImage.ImageUrl; var imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"images/" + image); var tranform = new Transformation().Crop("scale").Width(200).Height(200); var eagerTransform = new List <Transformation>() { new Transformation().Width(250).Height(250).Crop("thumb").Gravity("face").Radius(20).Effect("sepia"), new Transformation().Width(100).Height(150).Crop("fit") }; var imageId = image.Substring(0, 5); var uploadParams = new ImageUploadParams { File = new FileDescription(imagePath), PublicId = imageId, Transformation = tranform, EagerTransforms = eagerTransform, Tags = "Khophi_" + imageId, Folder = "/web", Overwrite = true, Colors = true }; var uploadResult = cloudinary.Upload(uploadParams); HackContext context = HttpContext.RequestServices.GetService(typeof(HackContext)) as HackContext; context.FillImageInfo(uploadResult, productImage.Name); return(uploadResult); }
public ImageUploadResult PostImageToServerAndProduct([FromBody] ProductImage productImage) { Cloudinary cloudinary; ImageUploadParams uploadParams; ProcessParams(productImage, out cloudinary, out uploadParams); var uploadResult = cloudinary.Upload(uploadParams); HackContext context = HttpContext.RequestServices.GetService(typeof(HackContext)) as HackContext; context.FillImageInfo(uploadResult, productImage.Name); context.FillImageWithProduct(uploadResult, productImage.Name, productImage.Price, productImage.Content, productImage.Implication, productImage.Reviews); return(uploadResult); }