Helper module used in general django applications
Project description
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
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-aid-0.1.4.tar.gz
(6.2 kB
view hashes)
Built Distribution
Close
Hashes for django_aid-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf3282cb31787d295b10d4bdefb59d232943f75c63cf615dfd49fd9c8c79f572 |
|
MD5 | 100e8a5c983308d4c00b41feb7522cf8 |
|
BLAKE2b-256 | aa55e0f7993dac3eaea71cc556978199a02514d032a38cb3b1ed138ed6ef3273 |