src/BoomCMS/Http/Controllers/Asset/AssetController.php
public function createFromBlob(Request $request, Site $site): array
    {
        $this->authorize('uploadAssets', $site);

        $file = $request->file('file');
        $error = $this->validateFile($file);

        if ($error !== true) {
            return [];
        }

        $description = trans('boomcms::asset.automatic-upload-description', [
            'url' => $request->input('url'),
        ]);

        $asset = AssetFacade::createFromFile($file);
        $asset->setDescription($description);
        AssetFacade::save($asset);

        $album = AlbumFacade::findOrCreate('Text editor uploads');
        $album->addAssets([$asset->getId()]);

        return [
            'location' => route('asset', ['asset' => $asset]),
        ];
    }
public function createFromBlob(Request $request, Site $site): array
    {
        $this->authorize('uploadAssets', $site);

        $file = $request->file('file');
        $error = $this->validateFile($file);

        if ($error !== true) {
            return [];
        }

        $description = trans('boomcms::asset.automatic-upload-description', [
            'url' => $request->input('url'),
        ]);

        $asset = AssetFacade::createFromFile($file);
        $asset->setDescription($description);
        AssetFacade::save($asset);

        $album = AlbumFacade::findOrCreate('Text editor uploads');
        $album->addAssets([$asset->getId()]);

        return [
            'location' => route('asset', ['asset' => $asset]),
        ];
    }
public function createFromBlob ( Request $ request , Site $ site ) : array { $ this -> authorize ( 'uploadAssets' , $ site ) ; $ file = $ request -> file ( 'file' ) ; $ error = $ this -> validateFile ( $ file ) ; if ( $ error !== true ) { return [ ] ; } $ description = trans ( 'boomcms::asset.automatic-upload-description' , [ 'url' => $ request -> input ( 'url' ) , ] ) ; $ asset = AssetFacade :: createFromFile ( $ file ) ; $ asset -> setDescription ( $ description ) ; AssetFacade :: save ( $ asset ) ; $ album = AlbumFacade :: findOrCreate ( 'Text editor uploads' ) ; $ album -> addAssets ( [ $ asset -> getId ( ) ] ) ; return [ 'location' => route ( 'asset' , [ 'asset' => $ asset ] ) , ] ; }
Controller for handling a single file upload from TinyMCE.

@see https://www.tinymce.com/docs/configure/file-image-upload/#automatic_uploads

@param Request $request

@return array
Controller for handling a single file upload from TinyMCE .