Categories
Uncategorized

Converting nopCommerce to Store Images In Filesystem Instead of Database

By default, nopCommerce stores all of the images in the database, making for simple access. However, with a lot of images, this puts a lot of load on the database, alongside making for a larger database to maintain.

Some research shows that the performance doesnt differ greatly between the two options, but here’s a few reasons you might use either:

Storing in Database

  • Allows for easier backups & environment clones (only need to clone codebase and DB)
  • Single place for image storage (useful with multiple systems)

Storing on Fileserver

  • Separates large portion of data from DB (allows for smaller DB)
  • Lowers load on DB server.

First, back up your database – since this is a process that can cause major issues if something were to go wrong (or if you decide to revert back to storing images in the database).

To convert from storing images in the database to the file server, go to Admin -> Settings -> Media Settings. Click on ‘Change’:

After the conversion completes, nopCommerce will automatically convert all images into the /Content/Images folder. You’ll also notice the binaries no longer being stored in the Picture table.

Shrink Database

Once this is done, you have the potential to open a good amount of space on the database, since the binaries of the images are now stored on the fileserver themselves.

To reclaim this space, you’ll need to shrink the database. Run the following command in SQL:

DBCC SHRINKDATABASE (YOUR_DB, 10);
GO

Leave a Reply

Your email address will not be published. Required fields are marked *