Beispiel #1
0
        /// <summary>
        /// Given pregenerated thumbor image parameters return URL to the image with signed key if one exists.
        /// NB should not include the leading /
        /// </summary>
        /// <param name="imageUrl">The image to produce the URL for EG. trim/100x200/filters:grayscale()/http://myserver/myimage.jpg </param>
        /// <returns>String containing the URL with the signed image.</returns>
        public string BuildSignedUrl(string imageUrl)
        {
            if (string.IsNullOrEmpty(this.thumborSecretKey))
            {
                return(string.Format("{0}unsafe{1}", this.thumborServerUrl, imageUrl));
            }

            var thumborSigner = new ThumborSigner();
            var signedKey     = thumborSigner.Encode(imageUrl, this.thumborSecretKey);

            return(string.Format("/{0}/{1}", signedKey, imageUrl));
        }