Storing Form Files with IFileSystem
Umbraco Forms available in version 4.4.0 and up to version 8 allows you to use an
IFileSystem to abstract how and where the physical JSON files such as Forms, Workflows and PreValues.
What on earth is an IFileSystem
To summarise this allows the saving & getting of files to be abstracted away to a provider, where it can save & retrieve say from Azure Blob Cloud storage or some other place. You can learn more about IFileSystems in the Umbraco core
Storing the JSON files in a different location on the server
This uses the Umbraco core IFileSystem provider
Umbraco.Core.IO.PhysicalFileSystem. With its property we can specify a different location than the default location than Umbraco Forms stores its files, which is
Adding the following to your IFileSystem config file found at
Config/FileSystemProviders.config will allow you to store the files elsewhere to suit your requirements
<Provider alias="forms" type="Umbraco.Core.IO.PhysicalFileSystem, Umbraco.Core"> <Parameters> <add key="virtualRoot" value="~/App_Data/Forms" /> </Parameters> </Provider>
Storing the JSON files using the community Umbraco Azure Blob Provider
The Umbraco community has created a great open source IFileSystem provider that is currently used for storing your media files in Azure Blob storage. The same provider can be installed and configured as below in the IFileSystem config file at
Note you may or may not have a similar looking configuration if using this provider to store your media files in Azure blob too, the differences here will be the
alias="forms" and the
containerName property of where you want to store your forms based data
<Provider alias="forms" type="Our.Umbraco.FileSystemProviders.Azure.AzureBlobFileSystem, Our.Umbraco.FileSystemProviders.Azure"> <Parameters> <add key="containerName" value="form-data"/> <add key="rootUrl" value="http://[ACCOUNTNAME].blob.core.windows.net/"/> <add key="connectionString" value="DefaultEndpointsProtocol=https;AccountName=[ACCOUNTNAME];AccountKey=[YOURACCOUNTKEY]"/> <!-- Optional configuration value determining the maximum number of days to cache items in the browser. Defaults to 365 days. --> <add key="maxDays" value="365"/> <!-- When true this allows the VirtualPathProvider to use the default "media" route prefix regardless of the container name. --> <add key="useDefaultRoute" value="true"/> </Parameters> </Provider>
The Azure Blob container cannot be called
forms as this will give unexpected behaviour, and we recommend you call it
form-data or similar.
Creating your own custom provider for your needs
This requires creating a C# class that inherits from the Umbraco Core CMS class
Umbraco.Core.IO.IFileSystem and implementing methods such as
public IEnumerable<string> GetDirectories(string path) and more.
With your provider written to retrieve folders, files you will need to update the FileSystem config file with the
alias="forms" to use your provider
type in the format of
For inspiration on creating a C# FileSystemProvider please take a look at the source code for the Azure provider
Forms containing upload fields
Any form containing an upload field will use the same IFileSystem provider with the
alias="media" to upload the submitted files in any form submission.