Selling Files

Many stores online deal in digital goods. Known Ubercart sites are already selling music, photos, movies, and more using the core file download system. Large sites like Riff Trax and corporations like AOL are using this system to sell and distribute files. Props go to early community member CpILL for getting the ball rolling and torgosPizza for his extensive testing and use of the system. Its creation was and its improvement continues to be a community effort.

Initial Setup


To start selling files, you need to make sure you have enabled the File Downloads module. The File Downloads module makes use of Ubercart's product feature system that lets you attach additional features to products (e.g. file download or discount). You can enable the module under Administer › Site building > Modules. Check the box next to File downloads and press the "Save settings" button.


After enabling the module, you'll want to set the permissions on who can access what parts of the module. You can do this by browsing to Administer › User management > Access control. This form will show you all the roles on your Drupal configuration and what permissions they have. You will want to scroll down to the permissions for the uc_file module. There are 2 permissions, "download file" & "view all downloads". The "download file" permission will allow a user to download files from the store. More than likely, you'll want to enable this permission for everyone (you might not want to check the permission for anonymous user if you want customers to be logged in before they can download files) The "view all downloads" permission will let a user view any files a customer has purchased by looking at their user page. You will only want to grant this role for a site or store administrator role.


You will also need to set up the file downloads directory that will be used to store all the digital products you will be selling for your store. If you haven't set it (or Ubercart can't find the directory you have specified), you will see a warning on the Store administration page (Administer > Store administration).
If you're perhaps wondering why you should have to specify a file download directory instead of using Drupal's files directory, a separate directory is needed for security reasons; specifying a directory outside of your web root prevents the possibility of someone figuring out where your files are stored and downloading them directly off your web server instead of paying for them. The file downloads directory is set up under Administer › Store administration › Configuration > Product settings > Product features. You should see a link that says File download settings, after clicking the link it should open up a form to specify settings for file downloads. It's here where you'll see the following settings:
Files path
This is the file directory for file downloads is specified. The path can be absolute (e.g. "C:\WWW\downloads" (Windows), "/www/downloads" (Linux)) or relative to Drupal root (e.g. "../downloads"). If you were insistent on using the Drupal file directory for downloads you could specify "files/downloads" as the path (assuming "files" was the name of your Drupal files directory and the directory "downloads" existed within that directory).
If you wish to impose a limit on the number of times that a user can download a file purchased, you can specify it here. Leaving the field empty will set no limit on the number of downloads.
IP addresses
If you wish to prevent the number IP addresses that can access the file you can specify it here. Leaving the field empty will set no limit on the number of addresses.
If you wish to specify an amount of time from when a file download granted that a user is allowed to download the file until expiration, you can set it here. By default, this is set to "never" which means there is no expiration on file downloads.
After filling out this form you can click the "Save settings" button to save your configurations.

Adding Files

Once your file download directory has been setup you're ready to start adding files to the directory so that they can be used for file downloads. There are two ways to do this. One is through the built in file manager located in Administer › Store administration › Products > View file downloads, this file manager shows all files located in your file directory (with products or SKUs are associated with them) and allows you to delete them or upload new files. Depending on your website's configuration, you might want to upload files that are too big for Ubercart to upload. In which case, you will have to use the second method, upload the files directly through a FTP/SFTP/SSH client to your file downloads directory. After uploading the files directly, they should appear in file manager.

Adding Files to Products

From here you must associate your Ubecart products with file downloads. This tutorial assumes the reader already knows how create an Ubercart product. If you do not you can reference ubercart product creation. Once your product is created you should see a "Features" tab on the product edit page. After clicking the "Features" link, you'll see a empty list of product features. Select "File download" from the Add a new feature select box and click "Add".
The next step is to fill out the feature form with the following details:
The Model/SKU of the product that grants the download. If the product you are selling is solely a download you'll want to keep this to "Any". If however the product you're selling has different SKU adjustments you might only want to grant a download on a specific SKU (e.g. a music album product might have 2 SKUs: one for the CD & for the album download).
File download
The name of the file (located in the file download directory) that can be downloaded upon purchase. Upon typing the file name, an auto complete box should appear showing the available files that start with the text typed. If there are any subdirectories in the file download directory, specifying a subdirectory here will grant all files within that subdirectory.
Upon typing "Tes", the file download module recognizes there is a file called "Test.txt"
A description of the file product. This text will be displayed alongside the file name on a customer's file download page.
Shippable product
This checkbox specifies whether the product associated with the download is shippable or not (if there are no shippable items in a customers order he won't be asked for a shipping address at checkout). If there is a shippable product included with this file download you will need to check this box, otherwise leave it blank.
After filling in the form, clicking "Save feature" will add the feature to your product. You should see the summary of the file download feature on the product feature page. You can click the "edit" link to change any details of the file download feature. Clicking the "delete" link will remove the file download feature altogether.

Customer Download

Here's a short YouTube screencast of a similar walk-through on the ubercart demo. At this point, any customers that purchase the product should have a file download granted once their order goes into the status you have specified. From here it is up to you to set up a conditional action that will move the order into the correct status once a customer has paid, and then to notify the customer where they can go to download the file they've purchased. Once a customer is granted a download they can go to My account > Files to download the file. If you wish to send the customer an email with the file download link, you can do so with the built in notification support. To do this make sure you enable the Conditional Actions predicate at Administer > Store administration > Conditional actions. The "Notify customer when a file is granted" predicate is enabled by default, and you can edit the recipients of the message under its Actions tab. From this point, you should know everything there is to create file products for your Ubercart store.