When first setting up a new Drupal site one of the things you have to choose is the type of File System access to use – either “Private” or “Public”. Of course you don’t have much information to help you make this life-altering decision other than what the Drupal File System configuration page tells you:
Choose the Public download method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.
If you are (or, were) a n00b like me, naturally you would choose the method which would would allow you to enforce fine-grained access controls over file downloads, aka the private filesystem option.
The only trouble with choosing to use the Private file system is that it will prevent you from activating options like “Optimize CSS files” and “Optimize Javascript files”. (That’s why both of these optimization options are grayed-out in your performance settings!) Using the private file system will also prevent you from using performance-enhancing modules like Javascript Aggregator. And, unless you are actually making use of those fine-grained access controls over file-downloads, you don’t even need your file system to be ‘private’.
So you may ask yourself, “why can’t I change from a private file system to public?” And the answer is the scary warning that you see on the Drupal File System settings page:
Changing this location will modify all download paths and may cause unexpected problems on an existing site
I stared at that warning-message for 5 years and finally decided to do some extensive research to see what would happen if I changed from my private file system to a public file system. After 10 minutes of Googl’ing and 5 minutes of reading, I learned it’s really not that big of a deal to change the file system type – so I gathered my courage, made my backups and made the change from a private to a public file system.
The change is simple: on your admin/settings/file-system page, just click from “private” to public and check through all of your pages – particularity pages with uploaded files or images. Of course, make a complete backup first, but if you see a bunch of broken pages and panic, it’s simple to just click back from public to private and it will put everything back the way it was.
I made this change on 3 sites of mine. On two sites, nothing happened, and everything worked perfectly. On one site, many of my uploaded images were returning “not found” – this is because just as the warning promised, some of the download paths had changed. Fixing the broken download paths was quick and painless.
Fixing the “not found” broken image paths:
Using Firebug or by looking at your page-source, find the broken image-path. In my case it was “/sysroot/files”. Then, find the correct/actual location of your images. In my case it was just “/files”. Now that you know the new path you can update all of your pages/nodes with two simple SQL updates.
The first update will fix any node bodies, and would look something like this:
update node_revisions set body = replace(body, '/sysroot/files', '/files')
The second, will fix any node-teasers, and will look like this:
update node_revisions set teaser = replace(teaser, "/sysroot/files", "/files")
If you have files/images in your comments, the update would look like this:
update comments set comment = replace(comment, '/sysroot/files', '/files')
That’s it! It took me less than 5 minutes to make the change from a private file system to a public file system and fix any damage. Of course, your mileage may vary, so be sure you have a good backup of your database before you change anything.