Package: jmbo-downloads
Jmbo Downloads User GuideJmbo Downloads allows you to easily create and serve downloadable content on your Jmbo sites. Files are uploaded via the admin interface, or generated per request,
and served by your webserver. These downloads can then be tracked - Jmbo Downloads, by default, tracks the total downloads for each item.To add or modify downloadable content, navigate to Downloads in the admin interface. A basic download lets you specify the file to be downloaded and, optionally, a file name to serve the file with.
Users can view all downloads by navigating to www.yoursite.com/downloads.InstallationAdddownloadsto INSTALLED_APPS.Runmanage.py migrate downloads(requires South).If you are using Nginx:Define an internal location at MEDIA_URL/downloads/(.*) in your site’s Nginx config.Set its alias to MEDIA_ROOT/downloads/$1.If you are using Jmbo with buildout, add this to the appropriate buildout template.If you are using another webserver you will have to specify the internal redirection header by puttingDOWNLOAD_INTERNAL_REDIRECT_HEADERin your settings.If files are hosted remotely setDOWNLOAD_SERVE_FROMto ‘REMOTE’. The client will be redirected to the remote location.RequirementsDjango 1.3 and aboveJmbo and all its requirementsSouthOther features (the fun stuff)Generated filesYou might want to serve a file that is generated on the fly, for example a PDF with the user’s details in it. You can do this by subclassingmodels.TemporaryDownloadAbstract.
The child class must implement the functiondef create_file(self, file_path, request). Generate your file in this function and save it atfile_path(it includes the file name).
You can use therequestobject to access theuserobject and query string parameters.You can optionally specify a file name and extension by overridingdef make_file_name(self, request). Call the superclass function and provide theextensionargument
to get a UUID + extension as the file name. Otherwise return your own unique file name. Keep in mind that the file will only be served with its on-disk name if the model’s file name field is empty.
If the field has been specified, all generated files are served with the specified file name.Only one implementation ofmodels.TemporaryDownloadAbstractis included with Jmbo Downloads:models.TextOverlayTemporaryDownload. This download takes a background image, draws some text on it and saves it as a JPEG.Note that all generated files are generated upon request and stored in MEDIA_ROOT/downloads/tmp/. You need to clear out this folder periodically to avoid running out of disk space.Tracking downloadsIf you would like to track more than just the number of downloads (or view count) per item you can implement a receiver forsignals.download_requested. The signal will pass a download instance (assender) and therequestobject to the receiver.
This allows for stats like downloads by time of day and a user’s favourite download categories to be tracked.
Authors
=======Praekelt FoundationRizmari VersfeldChangelog2.0.2Remove explicit jmbo version pin.2.0.1Guard against deletion error where database and filesystem is out of synch.2.0.0Stabilize on jmbo 2.0.0.2.0.0a1Get tests to pass again.Django 1.6 support.Up minimum jmbo to 2.0.0.0.0.8Correct calculation of download URL, particularly for temporary downloads.Lots of PEP8 fixes.0.0.7Temporary downloads adhere toDOWNLOAD_SERVE_FROMsetting. They are always created on the local filesystem though. If ‘REMOTE’ is used the developer needs to sync these files with a remote filesystem.0.0.6AddDOWNLOAD_INTERNAL_REDIRECT_HEADERsetting (default ‘X-Accel-Redirect’) in case a webserver other than Nginx is used.AddDOWNLOAD_SERVE_FROMsetting (default ‘LOCAL’) to specify whether to serve the files locally or redirect to a remote location.0.0.5Fix bug where X-Accel-Redirect uses file name override instead of actual file name to serve download, causing a 404 if the file name and override don’t match.0.0.4 (2012-06-21)South dependency on jmbo upped to 0002 migration.0.0.3 (2012-06-15)Improve templates to better render download categories.Override Jmbo’s PermittedManager to exclude invisible downloads from querysets.Make ImageMod more generic and rename it to TemporaryDownloadAbstract.Send signal when a download is requested, allowing other apps to track downloads.Miscellaneous small fixes.0.0.2Add everything to manifest for PyPI release.0.0.1 (2012-05-28)Initial release.