DRF-Base64 provides a set of serializers to handle Bas64-encoded files.
Compatibility Matrix
DRF-Base64 is compatible with the following matrix
Py 3.5 |
Py 3.6 |
Py 3.7 |
|
|---|---|---|---|
Django 2.0 |
DRF 3.7+ |
DRF 3.7+ |
DRF 3.7+ |
Django 2.1 |
DRF 3.7+ |
DRF 3.7+ |
DRF 3.7+ |
Django 2.2 |
DRF 3.7+ |
DRF 3.7+ |
DRF 3.7+ |
Installation
DRF-Base64 is compatible with Python 3.5+ as well as Django 2.0+ and DRF 3.7+
For previous versions of Python and/or Django, please see the V1.x branch
With pip
pip install drf-base64
From source
Within the source directory:
python setup.py install
Field Serializers
DRF-Base64 provides a Base64FileField and a Base64ImageField very similar to DRF’s FileField and ImageField with the added functionality of accepting base64-encoded file strings as input. If those serialiers receive an url (ie: when updating a record containing a file without modifying that said file), it will leave the existing value untouched.
Example usage:
from rest_framework import serializers
from base64.fields import Base64ImageField
from .models import Product
class ProductSerializer(serializers.ModelSerializer):
picture = Base64ImageField(required=False)
class Meta:
model = Product
...
Model Serializers
DRF-Base64 also provides a ModelSerializer and an HyperlinkedModelSerializer also similar to DRF’s own ModelSerializer and HyperlinkedModelSerializer with the added functionality of mapping django.db.models.FileField’s to Bas64FileField’s and django.db.models.ImageField’s to Base64ImageField’s.
Example usage:
from drf_base64.serializers import ModelSerializer
from .models import Product
class ProductSerializer(ModelSerializer):
class Meta:
model = Product
...
Mixins
drf_base64.fields.Base64FieldMixin
If you’d like to enable base64 uploading of file for other field types than FileField or ImageField, DRF-Base64 provides Base64FieldMixin to let you do just that.
drf_base64.serializers.Base64ModelSerializerMixin
If you wish to use Base64FileField and Base64ImageField as default for model serializers other than the ones provided, DRF-Base64 also provides Base64ModelSerializerMixin that you can apply on any other model serializer as long as they use `serializer_field_mapping <http://www.django-rest-framework.org/api-guide/serializers/#serializer_field_mapping>`__.
License information available here.
Contributors code of conduct is available here. Note that this COC will be enforced.
Metadata
Release files for drf_base64 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf_base64-2.0.tar.gz | 3.7 kB | Without provenance | Details for drf_base64-2.0.tar.gz |
Release files / drf_base64-2.0.tar.gz
| Download URL | drf_base64-2.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dee42f27e6ea5fb91ff85916ad1aaba222275552815430ff6a55a547e0246234
|
|
BLAKE2b-256 checksum How to use checksums |
481c090d49cbd04b5c5356d96725d5b1e57d931f008ec96b5fda5cd3dbaebb9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|
Security for drf_base64 2.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.