ks-adaptdev
-
2/7/2014 10:05:55 AM
RE:Media libraries folder storage location w/ Virtual Directory
Thanks FroggEye, another good tip. I had changed this particular setting at the global level. My site inherits it, and shows the same value, so I don't think that's an issue.
Have you ever configured the media library to point to a path that happens to be virtual? As someone who's new to Kentico, it's misleading how tilde "~/paths" work, at least as it pertains to the media library configuration. The tooltip says:
"Physical path to the folder where root folders of all media libraries should be stored. For example "~/Libraries", "c:/Libraries" or "\\servername\Libraries". If empty "~/[site name]/media" will be used."
Lets say my site lives at c:\wwwroot\site
So if I put in "~/Libraries" and then upload a file to the library, you'd expect it to end up physically saved on disk at c:\wwwroot\site\Libraries, with the url /Libraries/{file}. This is true.
But, configure the path "/Libraries" in IIS to be a virtual directory, which maps to the physical path of c:\files.
Again, we'll configure Kentico to use "~/Libraries". Upload a file, and you'd expect it to end up physically saved to disk at c:\files with the url /Libraries/{file}. This would be standard .net behavior assuming the code written to save the file calls Server.MapPath("~/Libraries") to determine the physical location. But this isn't what is happening.
Kentico ends up ignoring the fact that /Libraries is virtual, and saves the files physically on disk at c:\wwwroot\site\Libraries. This is not what one would expect. This means your files aren't saved where you wanted them and the Urls to them 404 because IIS is looking for the physical file at c:\files\{file}.
Does that make sense? Is there anything I'm missing?
Note: I'm aware I could just configure the media library w/ a physical path of c:\files instead of the virtual path, but I'm hosting the site on a cloud provider and technically I don't have control over the physical path of my system (it could change, be different across different instances, etc).
|