public function mimeType() {
        // if the type is known, return it
        if (!is_null($this->type)) {
            return $this->type;
        }
        
        // make sure the file is available to check
        $this->downloadFile();
        
        // get the file info
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        
        // get the MIME type of the file 
        $mime= finfo_file($finfo, $this->downloadFilePath());
        
        // clode the file info resource
        finfo_close($finfo);
        
        // store and return the file MIME type
        return $this->type = $mime;
    }