# Path: db_file_storage/compat.py



import base64
import os
from django.apps import apps
from django.core.files.base import ContentFile
from django.core.files.storage import Storage
from django.db.models import BinaryField
from django.utils.crypto import get_random_string
from django.utils.http import urlencode
from django.utils.deconstruct import deconstructible
from .compat import reverse
            mimetype_field_name: mimetype,
        })
        return new_filename

    def delete(self, name):
        if os.sep != '/':  # Windows fix (see a6d4707) # pragma: no cover
            name = name.replace('/', os.sep)
        storage_attrs = self._get_storage_attributes(name)
        model_class_path = storage_attrs['model_class_path']
        filename_field = storage_attrs['filename_field']

        model_cls = self._get_model_cls(model_class_path)
        model_cls.objects.filter(**{filename_field: name}).delete()

    def exists(self, name):
        if os.sep != '/':  # Windows fix (see a6d4707) # pragma: no cover
            name = name.replace('/', os.sep)
        try:
            storage_attrs = self._get_storage_attributes(name)
        except NameException:
            return False
        model_class_path = storage_attrs['model_class_path']
        filename_field = storage_attrs['filename_field']

        model_cls = self._get_model_cls(model_class_path)
        return model_cls.objects.filter(
            **{filename_field: name}
        ).exists()

    def url(self, name):

# Path: db_file_storage/compat.py



# Path: db_file_storage/storage.py
import base64
import os
from django.apps import apps
from django.core.files.base import ContentFile
from django.core.files.storage import Storage
from django.db.models import BinaryField
from django.utils.crypto import get_random_string
from django.utils.http import urlencode
from django.utils.deconstruct import deconstructible
from .compat import reverse

            mimetype_field_name: mimetype,
        })
        return new_filename

    def delete(self, name):
        if os.sep != '/':  # Windows fix (see a6d4707) # pragma: no cover
            name = name.replace('/', os.sep)
        storage_attrs = self._get_storage_attributes(name)
        model_class_path = storage_attrs['model_class_path']
        filename_field = storage_attrs['filename_field']

        model_cls = self._get_model_cls(model_class_path)
        model_cls.objects.filter(**{filename_field: name}).delete()

    def exists(self, name):
        if os.sep != '/':  # Windows fix (see a6d4707) # pragma: no cover
            name = name.replace('/', os.sep)
        try:
            storage_attrs = self._get_storage_attributes(name)
        except NameException:
            return False
        model_class_path = storage_attrs['model_class_path']
        filename_field = storage_attrs['filename_field']

        model_cls = self._get_model_cls(model_class_path)
        return model_cls.objects.filter(
            **{filename_field: name}
        ).exists()

    def url(self, name):

        _url = reverse('db_file_storage.download_file')