Motivation
In one of our customers environments it was very common that the grafics department used a well defined directory structure including sync with nextcloud to allow access from outside of the company network.
During the TYPO3 setup we recognized that our customers editors always did the following steps:
- Open Windows explorer
- Use preview functionality / view
- select a file, note or remember the file
- open TYPO3
File > Filelist
Module - Rebuild folder structure if the folders have been missing, to match the structure of the fileserver
- Upload image
- Edit content element
As you might see, we also recognized really fast that the first part of the process should be simplified.
Normally it should be like:
- Edit Content Element
To achieve that it’s essential that TYPO3 can access files in nextcloud like this:
Prerequisites
As described before we have some infrastructure prepared:
- TYPO3 7.6 running with PHP7
- Nextcloud 10 (now 11) (should also work with owncloud)
We used composer to install all the TYPO3 system, you may use the normal extension manager, but that is up to you.
Architecture
Luckily TYPO3 is extremely flexible due to the fact that the core ships a useable file abstraction layer since TYPO3 6.0.
This means that TYPO3 creates a database record to reference a file in TYPO3 and the database record points to a storage and an ID. Additionally the storage defines a so called driver, which allows us to extend the functionality of the file abstraction layer relatively easy.
Currently there are drivers available for:
- webdav
- ftp
- amazon s3
- dropbox
- ftp
See https://wiki.typo3.org/FAL_Adapters for details. Please be aware that some of these drivers are still in beta, and I strongly recommend to test them heavily before blindly using them.
Alternatively you can connect any of the filesystems which are supported by extensions to TYPO3 directly.
TYPO3 FAL --> Dropbox
--> Amazon S3
--> Webdav
--> SFTP
But the big advantage of using Nextcloud is that the well known Workflow inclusive Mobile Phone Upload / Sync, etc. is working directly with TYPO3. There is nothing technical complex the editor needs to take care of.
So our Architecture to access files will look like that:
TYPO3 FAL --> Nextcloud --> Dropbox
--> Amazon S3
--> Owncloud or other Nextcloud instances
--> SMB / CIFS
--> NFS
--> FTP
--> SFTP
--> ...
Process files and Downloads will be placed in the processed files folder, which could be on a different cloud storage.
Implementation
The setup will be devided into 2 parts:
- Configuration of nextcloud
- Configuration of TYPO3
Configuration of nextcloud
You could easily use an existing nextcloud user to connect to TYPO3, but this exposes all you files to FAL, so for security reasons I strongly suggest to create an dedicated user for TYPO3 FAL.
This also makes it possible to share files and folders to your TYPO3 by selecting the user in nextcloud, for every nextcloud user you have.
This also opens the door to all the services nextcloud can access as external file system.
Configuration of TYPO3
Start with installing the fal_webdav extension or the modified version.
- fal_webdav original
- fal_webdav patched
To configure the FAL driver you need to get your webdav URI from nextcloud.
Now it’s time to configure the related storage in TYPO3 (see rootpage with PID = 0
), please set it up like in the screenshot.
- Set your nextcloud URI and the credentials.
- Define the processed files folder, should be outside of the webdav driver. Normally
1:__processed__
should be ok. - Set your Storage to readonly.
Afterwards you can easily access all your files directly via the File > Filelist
module.
Thoughts about security
To make your system more robust against human mistakes and data loss, I suggests the following steps.
As the owner of files in nextcloud share only in readonly mode with the user, which is used with TYPO3. This ensures, files can not be removed from your shared folder.
To avoid problems, if one of your colleagues ignored the readonly sharing within nextcloud I also recommend to set the storage created in TYPO3 to readonly, so you have 2 layers, which ensure that no editor can accidently write or delete files in that storage.
But be aware, always keep a good backup.
Additional information
- File Abstraction Layer Reference - https://docs.typo3.org/typo3cms/FileAbstractionLayerReference/Index.html#start
- Installing Nextcloud - https://nextcloud.com/install/