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"
}

Contributing

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

Download files

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

Source Distribution

drf-base64-filename-0.1.4.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_base64_filename-0.1.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file drf-base64-filename-0.1.4.tar.gz.

File metadata

  • Download URL: drf-base64-filename-0.1.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.5

File hashes

Hashes for drf-base64-filename-0.1.4.tar.gz
Algorithm Hash digest
SHA256 77cfa79f82aadaebf908397e6517f860bcd989b54396a51015009b60d898bf1e
MD5 6bf056a78c102be33b2256dcf62ef89c
BLAKE2b-256 0b5d2e45d0f1b512551157e341d4a2c59d12b8062a156970c373b40b706db58a

See more details on using hashes here.

File details

Details for the file drf_base64_filename-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: drf_base64_filename-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.5

File hashes

Hashes for drf_base64_filename-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f0fa1e158c955c53ad102cc2966c521ab27ee2b68470efb6b3152d27fced26e
MD5 58deb8471332d11958b0709b60377e8e
BLAKE2b-256 2c6f66cafcd076f210d4d5c886e7d3d796ff7aaaafb6490bade31fc6225bd128

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

1 file

1.0.1

2 files

1.0.0

2 files

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 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