dev-task/travis-ci
dev-task/travis-ci
GPL-2.0+
The Requires
Little helper package for when you want to create files and save them to TYPO3's File Abstraction Layer, (*1)
FAL Filewriter is no TYPO3 extension and not available via TER. It can only be installed via composer:, (*2)
composer require smichaelsen/fal-filewriter
, (*3)
You need to create a class that provides the content that will be saved in a file. It has to implement the
\Smichaelsen\FalFilewriter\FileGeneratorInterface
, which is fairly easy., (*4)
By default your TYPO3 installation will have a storage record with uid 1
pointing to the fileadmin, but of course you
can configure your own storage records pointing to other folders or even to external services like AWS., (*5)
Load the storage object like this:, (*6)
$storage = $this->objectManager->get(\TYPO3\CMS\Core\Resource\StorageRepository::class)->findByUid($fileStorageUid);
The \Smichaelsen\FalFilewriter\FileWriterService
has one public method saveFile()
which takes the following parameters:, (*7)
FileGeneratorInterface
.$storage
folder. The file extension
may be omitted. Then it is read from the $fileGenerator
(->getFileExtension()
). If the file name starts with a path
that doesn't exist it will be tried to create that path. ResourceStorage
object to save the file in. See above ("Storage") for more information.As return value you will receive a \TYPO3\CMS\Core\Resource\FileInterface
object for the saved file., (*8)
Example:, (*9)
/** @var \Smichaelsen\FalFilewriter\FileWriterService $fileWriterService */ /** @var \Smichaelsen\FalFilewriter\FileGeneratorInterface $fileGenerator */ /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storage */ $fileObject = $fileWriterService->saveFile($fileGenerator, 'folder/my-filename', $storage);
GPL-2.0+