Remote Storing and Retrieving Images (e.g. Amazon S3)

Topics: ASP.NET 2.0, Business Logic Layer
Feb 10, 2009 at 5:08 PM
Hi there,
I've been working with BlogEngine.Net a bit recently and one request I've had was to be able to store uploaded images on Amazon S3 servers and load them from there when the blog post they were inserted into was loaded in a browser.

I tried using the JungleDisk tool to create a virtual drive and folder to route the App_Data settings in Web.Config to, but this caused IIS to crash when I tried to upload an image (not sure why).

I'm now thinking a more programmatic approach is needed, but I'm afraid of breaking future compatibility if I start editing the BlogEngine.Core framework or TinyMCE code to make this happen.

My idea instead was to create an Extension that would parse blog posts on saving for <img> tags, and then use the image at the 'src=...jpg' value as the source to be uploaded to Amazon S3, and then re-write the img's src tag with this new Amazon S3 URL once it successfully uploaded.

Either a cleanup script,run occassionally, or commands run right after saving the updated post(depending on loading times for the previous activities), would take care of deleting the App_Data stored images to recover disk space.

Does anyone forsee any complications with this approach? Is there an easier way in your opinion to get what I need to happen done?

Thanks in advance for any help you can offer.
-Nissan
Coordinator
Feb 10, 2009 at 5:20 PM
Your plan of creating an extension for this sounds like it would work well.

I'm not familiar with Amazon S3, but the only thing I might possibly look into is what mechanisms does Amazon S3 have to get files to them.  For instance, if they have a way you can post, FTP or upload a file to them, you could modify Add_entry.aspx.cs so it programmatically posts/ftps/uploads the image or file the user uploads directly to Amazon S3, instead of saving it to the App_Data folder.  If you could do this and get a url back at that time, then you could insert that url into the blog post at the same time.