def check_upload_permissions(request, bucket, key):
    from django.core.exceptions import ImproperlyConfigured
    from rest_framework.exceptions import PermissionDenied
    if bucket != upload_bucket():
        raise PermissionDenied(_("Bucket should be '%s'" % upload_bucket()))
    upload_prefix = upload_prefix_for_request(request)
    if upload_prefix is None or len(upload_prefix) == 0:
        raise ImproperlyConfigured(
            _('Upload prefix must be non-zero-length and should be unique for each user')
        )
    if not key.startswith(upload_prefix + '/'):
        raise PermissionDenied(_("Key should start with '%s/'" % upload_prefix))
Check permissions on the given upload policy. Raises
dataset/ETHPy150Open bodylabs/drf-to-s3/drf_to_s3/access_control.py/check_upload_permissions