Skip to main content

drf-base64-filename

drf-base64-filename provides Serializer fields for using base64-encoded files with file names.

Setup

Install drf-base64-filename to your Python environment

pip install drf-base64-filename

Usage

Sample Model

class SampleBase64ImageModel(models.Model):
    parent = models.ForeignKey(
        SampleParentModel, on_delete=models.CASCADE,
        related_name='image_set', blank=True, null=True)
    image = models.ImageField(blank=True)


class SampleBase64FileModel(models.Model):
    parent = models.ForeignKey(
        SampleParentModel, on_delete=models.CASCADE,
        related_name='file_set', blank=True, null=True)
    file = models.FileField(blank=True)

Serializer Field

class SampleNamedBase64ImageSerializer(serializers.ModelSerializer):
    image = NamedBase64ImageField(required=False, allow_null=True)

    class Meta:
        model = SampleBase64ImageModel
        fields = (
            'id',
            'image',
        )


class SampleNamedBase64FileSerializer(serializers.ModelSerializer):
    file = NamedBase64FileField(required=False, allow_null=True)

    class Meta:
        model = SampleBase64FileModel
        fields = (
            'id',
            'file',
        )

Sample request data

{
    "image": {
        "file_name": "pby.jpg",
        "encoded_str": "aHR0cHM6Ly9naXRodWIuY29tL2xlZWhhbnllb25n"
    }
}

Sample response data

{
    "image": "http://test/media/pby.jpg"
}

Test

❯ pip install -r requirements.txt
❯ cd test_project
❯ pytest

Contributing

As an open source project, we welcome contributions. The code lives on GitHub

Metadata

Release files for drf-base64-filename 1.0.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 drf-base64-filename 1.0.0
File Size Uploaded Provenance Actions
drf-base64-filename-1.0.0.tar.gz 2.9 kB Without provenance Details for drf-base64-filename-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for drf-base64-filename 1.0.0
File Interpreter ABI Platform Actions
drf_base64_filename-1.0.0-py3-none-any.whl Python 3 none any Details for drf_base64_filename-1.0.0-py3-none-any.whl

Total release size: 6.3 kB

Release files / drf-base64-filename-1.0.0.tar.gz

Download URL drf-base64-filename-1.0.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
62041485c334fc49de16ab95bd91d8e1cdba5ed652f1118beb6d4fed08d4000c
BLAKE2b-256 checksum
How to use checksums
4f28a74d7b13eebd0998c09af8c4c3751a1b46ca591590bbbc84be23f3b69d77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / drf_base64_filename-1.0.0-py3-none-any.whl

Download URL drf_base64_filename-1.0.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c955c01652462b023c8c0ee0eb83937bece3ead7ddc71135ffdd41f10f3d895
BLAKE2b-256 checksum
How to use checksums
1443ec252395cf9d140b1177196ff1795442163fd7f13a11d10e350e27d1fb39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for drf-base64-filename 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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