Skip to main content

Jmbo Downloads User Guide

Jmbo 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.

Installation

  1. Add downloads to INSTALLED_APPS.

  2. Run manage.py migrate downloads (requires South).

  3. 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.

  4. If you are using another webserver you will have to specify the internal redirection header by putting DOWNLOAD_INTERNAL_REDIRECT_HEADER in your settings.

  5. If files are hosted remotely set DOWNLOAD_SERVE_FROM to ‘REMOTE’. The client will be redirected to the remote location.

Requirements

  • Django 1.3 and above

  • Jmbo and all its requirements

  • South

Other features (the fun stuff)

Generated files

You 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 subclassing models.TemporaryDownloadAbstract. The child class must implement the function def create_file(self, file_path, request). Generate your file in this function and save it at file_path (it includes the file name). You can use the request object to access the user object and query string parameters.

You can optionally specify a file name and extension by overriding def make_file_name(self, request). Call the superclass function and provide the extension argument 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 of models.TemporaryDownloadAbstract is 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 downloads

If you would like to track more than just the number of downloads (or view count) per item you can implement a receiver for signals.download_requested. The signal will pass a download instance (as sender) and the request object 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 Foundation

  • Rizmari Versfeld

Changelog

2.0.2

  1. Remove explicit jmbo version pin.

2.0.1

  1. Guard against deletion error where database and filesystem is out of synch.

2.0.0

  1. Stabilize on jmbo 2.0.0.

2.0.0a1

  1. Get tests to pass again.

  2. Django 1.6 support.

  3. Up minimum jmbo to 2.0.0.

0.0.8

  1. Correct calculation of download URL, particularly for temporary downloads.

  2. Lots of PEP8 fixes.

0.0.7

  1. Temporary downloads adhere to DOWNLOAD_SERVE_FROM setting. 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.6

  1. Add DOWNLOAD_INTERNAL_REDIRECT_HEADER setting (default ‘X-Accel-Redirect’) in case a webserver other than Nginx is used.

  2. Add DOWNLOAD_SERVE_FROM setting (default ‘LOCAL’) to specify whether to serve the files locally or redirect to a remote location.

0.0.5

  1. Fix 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)

  1. South dependency on jmbo upped to 0002 migration.

0.0.3 (2012-06-15)

  1. Improve templates to better render download categories.

  2. Override Jmbo’s PermittedManager to exclude invisible downloads from querysets.

  3. Make ImageMod more generic and rename it to TemporaryDownloadAbstract.

  4. Send signal when a download is requested, allowing other apps to track downloads.

  5. Miscellaneous small fixes.

0.0.2

  1. Add everything to manifest for PyPI release.

0.0.1 (2012-05-28)

  1. Initial release.

Metadata

Release files for jmbo-downloads 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jmbo-downloads 2.0.2
File Size Uploaded
jmbo-downloads-2.0.2.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jmbo-downloads 2.0.2
File Interpreter ABI Platform
jmbo_downloads-2.0.2-py2.7.egg Legacy Egg format - - Details

Total release size: 67.5 kB

Release files / jmbo-downloads-2.0.2.tar.gz

Download URL jmbo-downloads-2.0.2.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5a4d0122cb65c3ed4305660e4750dcc3147d74b41932df42fadaa2604d006e12
BLAKE2b-256 checksum
How to use checksums
902303af166c484a8e0ea9bcb0eb97f200a9be4c8fb69c6c8efdae1e012dc6d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / jmbo_downloads-2.0.2-py2.7.egg

Download URL jmbo_downloads-2.0.2-py2.7.egg
Size 50.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
36d1cab9589624437ab90049c82f0a0041fae2481a453e42c13223a36dd375f4
BLAKE2b-256 checksum
How to use checksums
dad41ceef96c901809c346d0e712ef00d9bf9a068b2f8b51912c368b5fdf767f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

1 release file

0.0.5

3 release files

0.0.4

3 release files

0.0.3

3 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page