protected function store(UploadedFile $uploadedFile, Settings $settings)
    {
        // Fallback folder is none is set
        if (! $settings->hasFolder()) {
            $settings->setFolder('default');
        }

        try {
            // Retrieve folder path
            $path = public_path(config('nodes.assets.providers.publicFolder.subFolder')).DIRECTORY_SEPARATOR.$settings->getFolder();

            // If folder doesn't exists,
            // we'll create it with global permissions
            if (! file_exists($path)) {
                mkdir($path, 0777, true);
            }

            // Stream uploaded file
            $content = file_get_contents($uploadedFile->getPathname());

            // Save uploaded file to folder
            $result = file_put_contents($path.DIRECTORY_SEPARATOR.$settings->getFileName().'.'.$settings->getFileExtension(),
                $content);

            if (! $result) {
                throw new NodesException('Failed to save', 500);
            }
        } catch (Exception $e) {
            throw new AssetsUploadFailedException('Could not save the file to public folder. Reason: '.$e->getMessage());
        }

        return $settings->getFilePath();
    }
protected function store(UploadedFile $uploadedFile, Settings $settings)
    {
        // Fallback folder is none is set
        if (! $settings->hasFolder()) {
            $settings->setFolder('default');
        }

        try {
            // Retrieve folder path
            $path = public_path(config('nodes.assets.providers.publicFolder.subFolder')).DIRECTORY_SEPARATOR.$settings->getFolder();

            // If folder doesn't exists,
            // we'll create it with global permissions
            if (! file_exists($path)) {
                mkdir($path, 0777, true);
            }

            // Stream uploaded file
            $content = file_get_contents($uploadedFile->getPathname());

            // Save uploaded file to folder
            $result = file_put_contents($path.DIRECTORY_SEPARATOR.$settings->getFileName().'.'.$settings->getFileExtension(),
                $content);

            if (! $result) {
                throw new NodesException('Failed to save', 500);
            }
        } catch (Exception $e) {
            throw new AssetsUploadFailedException('Could not save the file to public folder. Reason: '.$e->getMessage());
        }

        return $settings->getFilePath();
    }
protected function store ( UploadedFile $ uploadedFile , Settings $ settings ) { // Fallback folder is none is set if ( ! $ settings -> hasFolder ( ) ) { $ settings -> setFolder ( 'default' ) ; } try { // Retrieve folder path $ path = public_path ( config ( 'nodes.assets.providers.publicFolder.subFolder' ) ) . DIRECTORY_SEPARATOR . $ settings -> getFolder ( ) ; // If folder doesn't exists, // we'll create it with global permissions if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } // Stream uploaded file $ content = file_get_contents ( $ uploadedFile -> getPathname ( ) ) ; // Save uploaded file to folder $ result = file_put_contents ( $ path . DIRECTORY_SEPARATOR . $ settings -> getFileName ( ) . '.' . $ settings -> getFileExtension ( ) , $ content ) ; if ( ! $ result ) { throw new NodesException ( 'Failed to save' , 500 ) ; } } catch ( Exception $ e ) { throw new AssetsUploadFailedException ( 'Could not save the file to public folder. Reason: ' . $ e -> getMessage ( ) ) ; } return $ settings -> getFilePath ( ) ; }
Save file to folder.

@author Casper Rasmussen <cr@nodes.dk>

@param  \Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile
@param  \Nodes\Assets\Upload\Settings                       $settings

@return string
@throws \Nodes\Assets\Upload\Exceptions\AssetsUploadFailedException
Save file to folder .