Media library root folder outside of CMS

Peter Otmar asked on February 27, 2019 04:06


we are in a process of moving all media library files to external storage. The issue we are facing is that when we point to external storage in Content->Media->Media libraries folder setting (e.g. e:/Library) we loose direct path access (e.g. ~/DancingGoat/media/CoffeeGallery/mug.jpg). The only way we can access it is by permanent link using GUID (e.g. /getmedia/df618225-62ac-4876-94bb-be75eae732fc/mug.jpg).

Is there some other setting we could utilize? I was also thinking about adding virtual directory in IIS.

Any ideas?



Recent Answers

Michal Samuhel answered on February 27, 2019 08:25

Hi Peter,

You could leverage file system provider to map external storage to one of the application folders. Should be just few lines of code:

0 votesVote for this answer Mark as a Correct answer

Peter Otmar answered on March 3, 2019 08:47

Thanks Michael however, that doesn't seem to work unless I am doing something really wrong. For example if I configure storage provider for media as bellow I still cannot access the files using relative path.

    protected override void OnInit()

    // Creates a new StorageProvider instance for the Windows file system
    var mediaProvider = StorageProvider.CreateFileSystemStorageProvider();

    // Specifies the target root directory. The provider creates the relative path of the mapped folders within the given directory.
    mediaProvider.CustomRootPath = @"D:\CustomMediaRoot";

    // Maps a directory to the provider
    StorageHelper.MapStoragePath("~/DancingGoat/Media", mediaProvider);

This code will store the media library in D:/CustomMediaRoot/DancingGoat/media but it is not accessible using direct path e.g. http://localhost/DancingGoat/Media/HomePage/banner-default.jpg


0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.