public EntryPictureFileContract(Stream uploadedFile, string mime, int contentLength = 0, ImagePurpose purpose = ImagePurpose.Unspesified) { UploadedFile = uploadedFile; Mime = mime ?? string.Empty; ContentLength = contentLength; Purpose = purpose; }
public EntryThumbContract(EntryThumb entryThumb) { EntryType = entryThumb.EntryType; Id = entryThumb.Id; Mime = entryThumb.Mime; _purpose = entryThumb.Purpose; Version = entryThumb.Version; }
/// <summary> /// Returns the uri for the proper image format requested. If the requested format isn't found, we sliently return nothing. /// </summary> /// <param name="WantedImageType"></param> /// <param name="displayCatalogModel"></param> /// <returns></returns> public static Uri GetImageUri(ImagePurpose WantedImageType, DisplayCatalogModel displayCatalogModel) { foreach (StoreLib.Models.Image image in displayCatalogModel.Product.LocalizedProperties[0].Images) { Uri imageUri; if (image.ImagePurpose == Enum.GetName(typeof(ImagePurpose), WantedImageType)) { if (image.Uri.StartsWith("//")) //For whatever reason, uris for images from UWP listings will start with "//", i.e //store-images.s-microsoft.com. Checking for that and adding http: to the beginning if they do to create a valid url. { imageUri = new Uri("http:" + image.Uri); return(imageUri); } imageUri = new Uri(image.Uri); return(imageUri); } } return(null); }
public EntryThumb(IEntryBase entry, string mime, ImagePurpose purpose) { Entry = entry; Mime = mime; Purpose = purpose; }
protected EntryPictureFileContract ParsePicture(HttpPostedFileBase pictureUpload, string fieldName, ImagePurpose purpose) { EntryPictureFileContract pictureData = null; if (Request.Files.Count > 0 && pictureUpload != null && pictureUpload.ContentLength > 0) { if (pictureUpload.ContentLength > ImageHelper.MaxImageSizeBytes) { ModelState.AddModelError(fieldName, "Picture file is too large."); return(null); } if (!ImageHelper.IsValidImageExtension(pictureUpload.FileName)) { ModelState.AddModelError(fieldName, "Picture format is not valid."); return(null); } pictureData = new EntryPictureFileContract(pictureUpload.InputStream, pictureUpload.ContentType, pictureUpload.ContentLength, purpose); pictureData.OriginalFileName = pictureUpload.FileName; } return(pictureData); }