Essential Drupal: Stage File Proxy
We can easily checkout code from our git repositories for our local, development, and staging servers. We can get a database from the live site through Backup and Migrate, drush, or a number of other ways. But getting the files of the site, the images, pdfs, and everything else in /sites/default/files is not on the top of the list of most developers. In recent versions of Backup and Migrate, you can export the files, but often times, this can be a huge archive file. There is an easier way.
The Stage File Proxy module saves the day by sending requests for files to the live server if it does not exist yet in your local environment. This saves you space on your non-production environment since it only grabs files from the pages you visit. Great for us that have dozens of sites on our local.
As simple as can be, it gets the files you need on your local server, as you need them. No more navigating broken looking dev sites. This will get your environment looking as it should so you can concentrate on your task at hand.
Installing and Configuring Stage File Proxy
// Download Stage File Proxy
drush dl -y stage_file_proxy
// Enable Stage File Proxy
drush en -y stage_file_proxy
// Set the origin, or where the files live, the production site
drush variable-set stage_file_proxy_origin "http://www.yoursitename.com"
You can also set it in your settings.php file, helpful for those of us who use different settings files per environment.
$conf['stage_file_proxy_origin'] = 'http://www.yoursitename.com'; // no trailing slash
Stage File Proxy has great documentation, and if Drush, or settings files aren't your thing, you can access configuration which can also be set in the admin UI at /config/system/stage_file_proxy, or Admin Menu > Configuration > System > Stage File Proxy.
This module is for use on your local, development, and staging servers, and should be used by anyone that works in multiple environments. It should be disabled on your production/live site.