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"]
        body = params["body"]
        index = params["index"]
        if not media_files:
            raise Http404
        if role not in media_files:
            raise Http404
        if (role == "streaming") and ("segment_info" not in body):
            raise ValueError(f"Streaming files are required to include a segment_info!")
        if (role == "streaming") and (not body["segment_info"]):
            raise ValueError(f"Streaming files are required to include a segment_info!")
        if index >= len(media_files[role]):
            raise ValueError(
                f"Supplied index {index} is larger than current array size "
                f"{len(media_files[role])}"
            )
        old_path = media_files[role][index]["path"]
        new_path = body["path"]
        check_resource_prefix(new_path, qs[0])
        if role == "streaming":
            old_segments = media_files[role][index]["segment_info"]
            new_segments = body["segment_info"]
        media_files[role][index] = body
        qs.update(media_files=media_files)
    media = Media.objects.get(pk=params["id"])
    if old_path != new_path:
        drop_media_from_resource(old_path, media)
        safe_delete(old_path, media.project.id)
        Resource.add_resource(new_path, media)
    if role == "streaming":
        if old_segments != new_segments:
            drop_media_from_resource(old_segments, media)
            safe_delete(old_segments, media.project.id)
            Resource.add_resource(new_segments, media)
    return {"message": f"Media file in media object {media.id} successfully updated!"}