public function createMediaInstance($fileSource, $classUri, $language, $label = null, $mimeType = null, $userId = null)
    {
        $clazz = $this->getClass($classUri);

        //create media instance
        if (is_null($label)) {
            $label = $fileSource instanceof File ? $fileSource->getBasename() : basename($fileSource);
        }
        $md5 = $fileSource instanceof File ? md5($fileSource->read()) : md5_file($fileSource);

        $link = $this->getFileManager()->storeFile($fileSource, $label);

        if ($link !== false) {
            if (is_null($mimeType)) {
                $mimeType = $fileSource instanceof File ? $fileSource->getMimeType() : \tao_helpers_File::getMimeType($fileSource);
            }
            $instance = $clazz->createInstanceWithProperties(array(
                OntologyRdfs::RDFS_LABEL => $label,
                self::PROPERTY_LINK => $link,
                self::PROPERTY_LANGUAGE => $language,
                self::PROPERTY_MD5 => $md5,
                self::PROPERTY_MIME_TYPE => $mimeType,
                self::PROPERTY_ALT_TEXT => $label
            ));

            if ($this->getServiceLocator()->get(common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoRevision')) {
                \common_Logger::i('Auto generating initial revision');
                $this->getServiceLocator()->get(Repository::SERVICE_ID)->commit($instance->getUri(), __('Initial import'), null, $userId);
            }
            return $instance->getUri();
        }
        return false;
    }