Reputation: 1583
I am using Umbraco CMS. I have a folder with of hundreds of jpg images and their filename have a naming convention. When I drag and drop this folder in the media section of the backoffice, it rearranges the files and its impossible to know the url to these images in advance. Manual image selection using media picker is not feasible due to sheer number of images. So I want to keep the image folder outside of umbraco and somehow pass the file-path to umbraco to display the image on template. Here is an Umbraco forum post that deals with this (see 2nd answer starting with "Solid idea"). It recommends to "map this folder" and do this:
File.exists(mappedPath + filename + ".jpg")
//If it existed I could just put a relative link in there (because I know the name of the folder), for example:
imgUrl = "/imgFolder/" + filename + ".jpg";
My question is how to do this "mappedPath". I mean, how to map a path to an external folder in umbraco. By external folder, I mean, it will be totally outside of umbraco, possibly in amazon cloud storage.
Upvotes: 0
Views: 1195
Reputation: 1985
To do this you would either need to do a virtual directory in IIS that maps this specific folder placed somewhere on the disk, to a virtual path below your site root (see: https://msdn.microsoft.com/en-us/library/bb763173.aspx). This is what he has been doing in the forum post you've linked to.
The second option is creating a module or handler that listens for specific requests (for example - anything matching a specific path) and if anything matches, it simply gets the image from your folder outside Umbraco and serves it to the client. This would also allow you to do authorization in case you needed that, instead of just serving the files like a static folder.
The first option should be just fine though for your case!
Upvotes: 1