src/Assets/AssetCatalogueProvider.php
public static function storeAsset($filePath, $category, $storeAs = "")
    {
        // A sane default
        $mime = "application/octet-stream";

        $name = ($storeAs == "") ? basename($filePath) : $storeAs;

        // CSV is detected as text/plain - change this if.
        if (preg_match("/\\.csv$/i", $name)){
            $mime = "text/csv";
        } else {
            if (function_exists("finfo_open")) {
                $info = new \finfo(FILEINFO_MIME);
                $mime = $info->file($filePath);
            }
        }

        $provider = self::getProvider($category);

        try {
            $asset = $provider->createAssetFromFile($filePath, [
                "name" => $name,
                "size" => filesize($filePath),
                "mimeType" => $mime,
                "category" => $category
            ]);

            $asset->mimeType = $mime;
            return $asset;
        } catch (AssetException $er){
            Log::error("Error creating asset from file '$filePath': ".$er->getPrivateMessage());
            throw $er;
        }

        return null;
    }
public static function storeAsset($filePath, $category, $storeAs = "")
    {
        // A sane default
        $mime = "application/octet-stream";

        $name = ($storeAs == "") ? basename($filePath) : $storeAs;

        // CSV is detected as text/plain - change this if.
        if (preg_match("/\\.csv$/i", $name)){
            $mime = "text/csv";
        } else {
            if (function_exists("finfo_open")) {
                $info = new \finfo(FILEINFO_MIME);
                $mime = $info->file($filePath);
            }
        }

        $provider = self::getProvider($category);

        try {
            $asset = $provider->createAssetFromFile($filePath, [
                "name" => $name,
                "size" => filesize($filePath),
                "mimeType" => $mime,
                "category" => $category
            ]);

            $asset->mimeType = $mime;
            return $asset;
        } catch (AssetException $er){
            Log::error("Error creating asset from file '$filePath': ".$er->getPrivateMessage());
            throw $er;
        }

        return null;
    }
public static function storeAsset ( $ filePath , $ category , $ storeAs = "" ) { // A sane default $ mime = "application/octet-stream" ; $ name = ( $ storeAs == "" ) ? basename ( $ filePath ) : $ storeAs ; // CSV is detected as text/plain - change this if. if ( preg_match ( "/\\.csv$/i" , $ name ) ) { $ mime = "text/csv" ; } else { if ( function_exists ( "finfo_open" ) ) { $ info = new \ finfo ( FILEINFO_MIME ) ; $ mime = $ info -> file ( $ filePath ) ; } } $ provider = self :: getProvider ( $ category ) ; try { $ asset = $ provider -> createAssetFromFile ( $ filePath , [ "name" => $ name , "size" => filesize ( $ filePath ) , "mimeType" => $ mime , "category" => $ category ] ) ; $ asset -> mimeType = $ mime ; return $ asset ; } catch ( AssetException $ er ) { Log :: error ( "Error creating asset from file '$filePath': " . $ er -> getPrivateMessage ( ) ) ; throw $ er ; } return null ; }
Stores an asset currently held in a local file in a given asset category

@param string $filePath
@param string $category
@return Asset
Stores an asset currently held in a local file in a given asset category