internal string CropResizeAndUpload(int height, int width, HttpPostedFileBase file)
{
if (file == null || !Utilities.IsImageFile(file.FileName)) return null;
var bitmapImage = new Bitmap(file.InputStream);
const CannedAcl acl = CannedAcl.PublicRead;
var s3 = new S3Service
{
AccessKeyID = AmazonCloudConfigs.AmazonAccessKey,
SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey
};
Image fullPhoto = bitmapImage;
string fileNameFull = Utilities.CreateUniqueContentFilename(file);
fullPhoto = ImageResize.Crop(fullPhoto, height, width, ImageResize.AnchorPosition.Center);
Stream maker = fullPhoto.ToAStream(ImageFormat.Jpeg);
s3.AddObject(
maker,
maker.Length,
AmazonCloudConfigs.AmazonBucketName,
fileNameFull,
file.ContentType,
acl);
return fileNameFull;
}