def METHOD_NAME(self, params):
    with transaction.atomic():
        qs = Media.objects.select_for_update().filter(pk=params["id"])
        if qs.count() != 1:
            raise Http404
        media_files = qs[0].media_files
        role = params["role"]
        index = params["index"]
        if not media_files:
            raise Http404
        if role not in media_files:
            raise Http404
        if index >= len(media_files[role]):
            raise ValueError(
                f"Supplied index {index} is larger than current array size "
                f"{len(media_files[role])}"
            )
        deleted = media_files[role].pop(index)
        qs.update(media_files=media_files)
    media = Media.objects.get(pk=params["id"])
    drop_media_from_resource(deleted["path"], media)
    safe_delete(deleted["path"], media.project.id)
    if role == "streaming":
        drop_media_from_resource(deleted["segment_info"], media)
        safe_delete(deleted["segment_info"], media.project.id)
    return {"message": f'Media file in media object {params["id"]} successfully deleted!'}