SilverCommerce\DownloadableProducts\FileDownloadController
Controller responsible for downloading the resticted file (if the user is allowed).
This class will take the file URL, check if the current member (if
there is one) is allowed to download the file. If not, it will check
the URL and compare it to the link life of the file (if valid).
Synopsis
class FileDownloadController
extends Controller
{
- // members
- private static integer $min_download_bandwidth = 50;
- private static string $url_segment = "downloadproduct";
- private static array $url_handlers = ;
- // methods
- public string DownloadLink()
- public string Link()
- public string AbsoluteLink()
- public HTTPResponse index()
- protected int|boolean sendFile()
Hierarchy
Extends
- SilverStripe\Control\Controller
Members
private
- $min_download_bandwidth
—
int
Calculate a timelimit based on the filesize. Set to 0 to give unlimited timelimit. The calculation is: give enough time for the user with x kB/s connection to donwload the entire file. -
$url_handlers
{@inheritdoc} - $url_segment
—
string
The base URL segment this controller will be accessed via
Methods
protected
- sendFile() — Output file to the browser as a stream.
public
- AbsoluteLink() — Get absolute URL to download a file.
- DownloadLink() — Generate a link to this controller for downloading a file
- Link() — Get a URL to download a file.
- index() — Main action for this controller, it handles the security checks and then returns the file, or either an error or a login screen.