How to store Media files in File System instead of Database?

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:

  1. Media.UploadAsFiles
  2. Media.DisableFileMedia
  3. Media.FileFolder

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.

  1. Open Sitecore.config under App_Config folder, and search for “Media.UploadAsFiles” and change the value to true
    Media.UploadasFileSetting
  2. The other config file is “ScalabilitySettings.config.example” under App_Config\Include\Examples.
    ScalabilitySettings
  3. We need to copy this file under Include folder and remove the file extension “.example”
    Include Folder
  4. Open the file and verify if both the settings – “Media.DisableFileMedia” & “Media.FileFolder” are present.
    ScalabilitySettings_Values
  5. If you have noticed the value of “Media.FileFolder”, the path is “/App_Data/Replicated/MediaFiles” which is not present by default.
  6. So either you can change the value of it or create that path.
  7. In this blog, I have created that path.
    File System path
  8. Lets try to upload a file in the Media Library and check if it is saved in the file System.
  9. Go to Sitecore >> Desktop >> Media Library.
    Media Library
  10. Click on the Media folder under which you want to upload the file/s and click Upload Files.
    Upload Files
  11. Upload the media file/s of your choice.
  12. Once it is successfully uploaded, verify if it is present in the File system at path which we specified.
    Media File

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.. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s