sunnysideup / download
Helps you set up a basic download controller
Package info
github.com/sunnysideup/silverstripe-download
Type:silverstripe-vendormodule
pkg:composer/sunnysideup/download
Requires
- silverstripe/admin: ^2.0
- silverstripe/framework: ^5.0
Requires (Dev)
- silverleague/ideannotator: *
- sunnysideup/sswebpack_engine_only: dev-master
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
TL;DR
How to setup:
1. extend DownloadFile to add extra functionality / configure how you see fit.
namespace Website\App\Control; use Sunnysideup\Download\DownloadFile; class MyDownloadFile extends DownloadFile { protected function getCallbackToCreateDownloadFile(): function { return function() { return $this->renderWith(static::class); }; } protected function getMaxAgeInMinutes() : int { return null; // set to null to use default } protected function getDeleteOnFlush() : ?bool { return null; // set to null to use default } // more fx goes here... protected function getContentType(): string { return 'text/csv'; } protected function getFileName(): string { return 'mydownload.' . $this->getExtension(); } protected function getExtension(): string { return '.csv'; } }
2. add a route to your file
--- Name: app_downloads_routes --- SilverStripe\Control\Director: rules: mydownload.csv: Website\App\Control\MyDownloadFile
3. add a template in themes/mytheme/templates/Website/App/Control/MyDownloadFile.ss
CSV content goes here...
Requirements
See composer.json for details.
Suggested modules
See composer.json for details.
Installation
composer require jq
Configuration
In the _config folder you will find the download.yml.example
file that shows options for the configuration of this module.
We recommend that you:
- copy these
download.yml.examplefiles into yourapp/_configfolder (where available - otherwise search forprivate static $in the module to see what can be configured) - remove the .example extension,
- delete the lines you do not care about, and
- adjust the configurations that you would like to use.
Contributing
We welcome any contributions. See CONTRIBUTING.md for more details.
Paid assistance
You can pay us to create an improved / adapted version of this module for your own projects. Please contact us if you like to find out more: www.sunnysideup.co.nz. For example, we can write tests for this module.
Author
Sunny Side Up Ltd.
Looking for Silverstripe Modules?
To find other modules, please visit ssmods.com.