You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
import mimetypes
|
|
|
|
|
|
def serialize(instance, file_attr='file'):
|
|
obj = getattr(instance, file_attr)
|
|
return {
|
|
'id': instance.id,
|
|
'url': obj.url,
|
|
'name': obj.name,
|
|
'type': mimetypes.guess_type(obj.path)[0] or 'image/png',
|
|
'size': obj.size,
|
|
'deleteUrl': '/delete',
|
|
'deleteType': 'DELETE',
|
|
}
|
|
|