The Remote File Source module allows you to select files that are on an external server, without having to save them to your Drupal files directory. This can be particularly useful for files that update regularly (like the master branch of a Drupal module) or for files that you just simply don't want to serve from your web server. In this example, I'll select the latest version of the FileField Sources zip file on drupal.org.
Install modules
Enable modules
- Go to "Modules" (admin/modules) and enable:
- Remote stream wrapper
- Remote File Source
- (Save configuration)
Enable the Remote File Option
- Go to “Structure => Content types => Article => Manage fields => File Upload” (admin/structure/types/manage/article/fields/field_file_upload)
- Click "File Sources"
- [x] Remote File
- (Save settings)
Now, we can create an article, and reference a remote file.
- Go to “Content => Add content = > Article” (node/add/article)
- Title: Article #6
- Body: (Lorem Ipsum)
- Click "Remote File"
- In another tab I'll go to "https://www.drupal.org/project/remote_file_source"
- In the Downloads section, I'll right click on the zip file link and select "Copy link address"
- Go back on the site and paste the link in the "File Upload" field
- Click "Select"
- (Save)
Now, if we hover over the file link, you'll see that it is pointing directly to ftp.drupal.org and not our site. We can also check our files directory, where we'll see that the file is nowhere to be found. This means that when visitors click this link, they will download the file directly from ftp.drupal.org without affecting our site.