This is a migrated thread and some comments may be shown as answers.

RadEditor Image Urls & Amazon S3

2 Answers 158 Views
Editor
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 14 Feb 2012, 06:32 PM
I'm using the RadEditor with a ContentTypeProvider that uploads images to the Amazon S3 service. That works great, but the imageManager sets the src of the image as src='S3FileSystemHandler.ashx?path=yourFolder/yourImage.jpg'. I'd rather not have the ashx page handling the images, and would prefer the src just be src='http://s3.amazonaws.com/yourBucket/yourFolder/yourImage.jpg'. Is this possible? Is there a reason I'm missing to set the src to include the ashx page and have the ashx page handle the images rather than just hitting the image directly?

Thanks for any help.
Jim

2 Answers, 1 is accepted

Sort by
0
Accepted
Dobromir
Telerik team
answered on 17 Feb 2012, 08:33 AM
Hi Jim,

The path of the image inserted by ImageManager dialog comes from the URL parameter of the FileItem. In order to achieve the required result, you need to modify the GetFiles() method of the content provider and set the direct path to the image to the URL parameter, e.g.:
private FileItem[] GetFiles(string realDirectoryPath)
{
    List<FileItem> filesResult = new List<FileItem>();
    List<XmlNode> responseResult = ListBucket(realDirectoryPath);
    foreach (XmlNode content in responseResult)
    {
        string key = GetKeyNode(content).InnerText;
        if (!key.EndsWith("_$folder$"))
        {
            // This is a file, not a folder
            string size = GetSizeNode(content).InnerText;
            string url = HttpUtility.UrlEncode(key);
            string fileName = VirtualPathUtility.GetFileName("/" + key);
 
            FileItem fileItem = new FileItem(fileName, VirtualPathUtility.GetExtension(key), int.Parse(size), string.Empty, url, string.Empty, GetPermissions(key));
 
            filesResult.Add(fileItem);
        }
    }
 
    return filesResult.ToArray();
}

The usage of a Handler in the content provider is required in case where the bucket is not public or you need do not want to expose the real image URL.

Regards,
Dobromir
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
James
Top achievements
Rank 1
answered on 21 Feb 2012, 10:20 PM
Perfect. Thanks Dobromir, that's just what I needed.
Tags
Editor
Asked by
James
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
James
Top achievements
Rank 1
Share this question
or