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.5.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.5-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: drf-base64-filename-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 b9f472bec519025432ab1b9b69128a6fa5320dc669899c0c002f66aa2fc100b8
MD5 fdf3b01c07f28dec34f2fa43b0cb03b5
BLAKE2b-256 adc86bc912f24310f2dcfd7e0b8e86c5268b849d02405d8b5999bc3d3d59838c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drf_base64_filename-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.9 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e09716d870d08f4c8b409878fb9b44d0e23d574911fb931fb913225ea92a20
MD5 f2830d0ec32b5d9ae8cf84d4afc15bd1
BLAKE2b-256 c4cabe842c75efdb61af1d190cf9e939c0429ffe0cb0306f41ab63a250d04d1e

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

This release

0.1.5 This release

2 files

0.1.4

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