chore: add some encoder type

This commit is contained in:
CaptainB 2025-03-18 11:10:39 +08:00 committed by 刘瑞斌
parent 075646481d
commit bf6cfface6

View File

@ -11,7 +11,7 @@ import decimal
import json
import uuid
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
class SystemEncoder(json.JSONEncoder):
@ -24,5 +24,7 @@ class SystemEncoder(json.JSONEncoder):
return float(obj)
if isinstance(obj, InMemoryUploadedFile):
return {'name': obj.name, 'size': obj.size}
if isinstance(obj, TemporaryUploadedFile):
return {'name': obj.name, 'size': obj.size}
else:
return json.JSONEncoder.default(self, obj)