public S3Info GetMediaInfo(IEclUri eclUri) { GetObjectResponse s3Obj; var mediaKey = eclUri.ItemId; GetObjectRequest request = new GetObjectRequest { BucketName = BucketName, Key = eclUri.ItemId, }; try { s3Obj = s3Client.GetObject(request); var mediaUrl = GetMediaUrl(mediaKey); S3Info s3Info = new S3Info(s3Obj, mediaUrl, eclUri.ItemType.ToString()); return(s3Info); } catch (KeyNotFoundException) { throw new KeyNotFoundException(); } catch (Exception ex) { return(null); } }
public static string GetPhotoUrl(S3Info photo, PhotoSizeEnum size) { string baseUrl = photo.MediaUrl; string url = string.Format("{0}?{1}", baseUrl, size.Description()); return(url); }
public static string GetPhotoUrl(S3Info photo, int width = MaxWidth) { if (width >= MaxWidth) { // width 1024, height 768 return(GetPhotoUrl(photo, PhotoSizeEnum.Large)); } if (width >= 800) { // width 800, height 600 return(GetPhotoUrl(photo, PhotoSizeEnum.Svga)); } if (width >= 640) { // width 640, height 480 return(GetPhotoUrl(photo, PhotoSizeEnum.Vga)); } if (width >= 500) { // width 500, height 375 return(GetPhotoUrl(photo, PhotoSizeEnum.Medium)); } if (width >= 320) { // width 320, height 240 return(GetPhotoUrl(photo, PhotoSizeEnum.Qvga)); } if (width >= 240) { // width 240, height 180 return(GetPhotoUrl(photo, PhotoSizeEnum.Small)); } if (width >= 150) { // width 150, height 150 return(GetPhotoUrl(photo, PhotoSizeEnum.LargeSquare)); } if (width >= 100) { // width 100, height 75 return(GetPhotoUrl(photo, PhotoSizeEnum.Thumbnail)); } // width 75, height 75 return(GetPhotoUrl(photo, PhotoSizeEnum.Square)); }