Skip to main content

FileField security validators: FileExtensionValidator, FileContentMatchesWithFileExtensionValidator.

Project description

django-content-safe-uploader

FileField security validators: FileExtensionValidator, FileContentMatchesWithFileExtensionValidator.

Install

pip install django-content-safe-uploader

Usage

pro/settings.py

INSTALLED_APPS = [
    ...
    "django_content_safe_uploader",
    ...
]

app/models.py

from django.db import models
from django_content_safe_uploader.validators import FileExtensionValidator
from django_content_safe_uploader.validators import FileContentMatchesWithFileExtensionValidator
from django_content_safe_uploader.validators import IMAGE_EXTENSIONS

class Book(models.Model):
    title = models.CharField(max_length=128)
    preview = models.FileField(
        upload_to="book_previews",
        validators=[
            FileExtensionValidator(*IMAGE_EXTENSIONS),
            FileContentMatchesWithFileExtensionValidator(lax_extensions=[IMAGE_EXTENSIONS]),
        ])

Release

v0.1.0

  • First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-content-safe-uploader-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-content-safe-uploader-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-content-safe-uploader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c323d705deb8ca83d553ab61a023618e6b816416c44ef657e14b4ad882a7e18
MD5 ba2a014cdea20d15a000e2504a4bc889
BLAKE2b-256 bd3e59b28487cd34719ea026c0cce2a697e3b01e814cdfee5ebfbaf2df192513

See more details on using hashes here.

File details

Details for the file django_content_safe_uploader-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_content_safe_uploader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c01114d7219f2295bc815d4e6eb966661a41eddb30ff48ff1d2bd151dedb515
MD5 9a8d1311f1b8053ae352b68eb4952e3e
BLAKE2b-256 bff3a90ecfd912e821883b99c2eae1431565ebf0491213888bb4c66d3678b343

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page