The default behavior of Sitecore is that it stores the media files (Images, Videos, docs, etc.) in the database. This is good feature as your website folder won’t grow as the Media items grow in Sitecore but the database size will keep growing over the period of time. It is not arguable over which approach is the best but you should analyze your requirements to select one of the above.
In this blog, we will learn how to change the default behavior of storing media files in database to storing it to file system.
Note: I am writing the steps relevant to Sitecore 9.3 version. The steps might be irrelevant to newer versions or prior to Sitecore 9.3.
There are basically 3 settings involved to change the default behavior:
All these settings were part of same config file prior to 9.x versions of Sitecore i.e. Sitecore.config but now in Sitecore 9.3, these files are present in 2 different configs.
- Open Sitecore.config under App_Config folder, and search for “Media.UploadAsFiles” and change the value to true
- The other config file is “ScalabilitySettings.config.example” under App_Config\Include\Examples.
- We need to copy this file under Include folder and remove the file extension “.example”
- Open the file and verify if both the settings – “Media.DisableFileMedia” & “Media.FileFolder” are present.
- If you have noticed the value of “Media.FileFolder”, the path is “/App_Data/Replicated/MediaFiles” which is not present by default.
- So either you can change the value of it or create that path.
- In this blog, I have created that path.
- Lets try to upload a file in the Media Library and check if it is saved in the file System.
- Go to Sitecore >> Desktop >> Media Library.
- Click on the Media folder under which you want to upload the file/s and click Upload Files.
- Upload the media file/s of your choice.
- Once it is successfully uploaded, verify if it is present in the File system at path which we specified.
In this blog, we learnt about uploading files only to the file system. With the above settings you won’t be able to ever switch the uploading of the file to database so please analyze the requirements before implementing this approach.
Thank you.. Keep Learning.. Keep Sitecoring.. 🙂