private function sanitize($filename)
    {
        $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename);
        return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-');
    }