Serializers: handle our variant of b64 (no padding, urlsafe).
This commit is contained in:
parent
9b13404ce7
commit
cf06534d6d
@ -29,10 +29,11 @@ def generate_rev_uid(length=32):
|
||||
|
||||
class BinaryBase64Field(serializers.Field):
|
||||
def to_representation(self, value):
|
||||
return base64.b64encode(value).decode('ascii')
|
||||
return base64.urlsafe_b64encode(value).decode('ascii')
|
||||
|
||||
def to_internal_value(self, data):
|
||||
return base64.b64decode(data)
|
||||
data += "=" * ((4 - len(data) % 4) % 4)
|
||||
return base64.urlsafe_b64decode(data)
|
||||
|
||||
|
||||
class CollectionEncryptionKeyField(BinaryBase64Field):
|
||||
|
Loading…
Reference in New Issue
Block a user