Skip to main content

django-pzip-storage

A FileSystemStorage subclass for Django that encrypts/compresses with PZip.

Installation

pip install django-pzip-storage

Usage

The simplest way to use PZipStorage is by setting your DEFAULT_FILE_STORAGE to pzip_storage.PZipStorage. By default, PZipStorage will use your SECRET_KEY setting as the encryption key.

IMPORTANT: Encrypting with SECRET_KEY means you must keep SECRET_KEY a secret, and if you lose or reset it without first rotating the keys of all stored files, they will be lost forever.

PZipStorage may be used with existing unencrypted files, as a drop-in replacement for FileSystemStorage. If it determined the requested file is not a PZip file, it will delegate to FileSystemStorage after emitting a needs_encryption signal (see below).

You may also use PZipStorage as a custom storage backend anywhere Django allows it; see Managing Files in the Django documentation for more information.

Settings

  • PZIP_STORAGE_EXTENSION - the extension to append to any file saved with PZipStorage. Defaults to .pz.
  • PZIP_STORAGE_NOCOMPRESS - a set of file extensions (with leading period) which should not be compressed when saving. See PZipStorage.DEFAULT_NOCOMPRESS for the default list.
  • PZIP_STORAGE_KEYS - an iterable (or callable returning an iterable) of keys to use. The first key on the list will be used for encrypting files. Defaults to PZipStorage.default_keys, which yields SECRET_KEY.

These settings may be overridden on a per-storage basis by instantiating PZipStorage manually with extension or nocompress keyword arguments.

Signals

PZipStorage emits a number of signals when opening files in various circumstances:

  • pzip_storage.needs_rotation - sent when a file was decrypted using an old key, i.e. not the first key in the provided list.
  • pzip_storage.needs_encryption - sent when an unencrypted file was opened.
  • pzip_storage.bad_keys - sent when an encrypted file was opened, but no keys in the list could decrypt it.

You may listen for these signals to do things like gradual encryption, key rotation, or logging.

Release files for django-pzip-storage 1.3.0

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

Source distribution (sdist)

Source distribution for django-pzip-storage 1.3.0
File Size Uploaded
django_pzip_storage-1.3.0.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-pzip-storage 1.3.0
File Interpreter ABI Platform
django_pzip_storage-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / django_pzip_storage-1.3.0.tar.gz

Download URL django_pzip_storage-1.3.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
59e05a6b81cf6c3a14aefb0f06235e16e8840f1d8ca2b84215675e50478f2c47
BLAKE2b-256 checksum
How to use checksums
60962fc5e3455afedc675bfef74ea0d40db3c26fca97162216891479d194a8fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / django_pzip_storage-1.3.0-py3-none-any.whl

Download URL django_pzip_storage-1.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4a812b0fe613ae5ee23ac17775ba66614e9fc036515bb7fa897432891e25eb6
BLAKE2b-256 checksum
How to use checksums
5c91de4df25df8c8e705f6e6e397757034398878be37170c100e41c4e7a06936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.9

2 release files

0.9.1

1 release file

0.9.0

1 release file

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