You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

File

File is the base type for all types that need to handle binary data / files etc. The binary data of a file is not stored in the database, but in an index tree folder structure on disk.

File extends AbstractNode and provides the following additional properties.

Name Type Description
contentType String The MIME type of this file
relativeFilePath String The relative path of the actual binary file on disk
size Integer The size of the file on disk
url String The URL
checksum Long The CRC32 checksum of the file’s contents
cacheForSeconds Integer A value that controls the simple caching behaviour for this file
version Integer The version, will be increased by one for each modification to the file or its metadata
isFile Boolean A read-only value that will always be true for all File types and their subtypes
base64Data2.0.2 String, input only A special property that can be used to Create a File from a Base64 string

Search results for "File"

copy_file_contents()

Copies the content of sourceFile to targetFile and updates the meta-data accordingly.

copy_file_contents(sourceFile, targetFile)

Deployment Format

folder / filedescription
componentsContains the shared components of the pages editor of Structr.
filesContains all files out of Sturctr’s virtual filesystem. Folders and files in the virtual filesystem are not being exported by default. If you want to include a folder or file into the export you have to set the flag includeInFrontendExport on each file or folder. Each file or folder will inherit this flag from its parent folder.
mail-templatesContains the mail-templates.
modulesContains the application configuration and definition of additional modules of Structr e.g. the flow engine.
pagesContains the created pages in the pages editor of Structr.
schemaContains the schema definition and code entered in the schema and code section of the Structr UI.
securityContains the resource access grants defined in the security section of the Structr UI.
templatesContains all template elements of the pages editor of Structr.
application-configuration-data.jsonContains the configured schema layouts of Structr’s schema editor.
components.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the components folder of the export.
deploy.confContains information about the Structr system that created the export of the application.
files.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the files folder of the export.
localizations.jsonContains the localizations that where created in the localizations section of the Structr UI and that can be used in server side scripting with the localize() function of Structr.
mail-templates.jsonContains the settings e.g. visiblity flags, locale or uuid for each file in the mail-templates folder of the export.
pages.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the pages folder of the export.
pre-deploy.confScript that is run before deployment import. Use this to create users who are granted access to nodes in the export files.
post-deploy.confScript that is run after deployment import. Can be used to start any tasks which are necessary after import.
sites.jsonContains sites that are configured in the pages section of the Structr UI.
templates.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the templates folder of the export.
widget.jsonContains the widgets that were created in the pages section of the Structr UI.

Filesystem

application.filesystem.enabled Enables the creation of home directories for each users.
application.filesystem.unique.paths Enforces unique paths for files and folders.
application.filesystem.unique.insertionposition
startprefixes the name with a timestamp
beforeextensionputs the timestamp before the last dot (or at the end if the name does not contain a dot)
endappends the timestamp after the complete name
application.filesystem.checksums.default List of checksums to be calculated on file creation by default.
application.filesystem.indexing.enabled Globally enables indexing. Indexing can still be controlled on a file basis.
application.filesystem.indexing.maxsize Maximum size (MB) for a file to be indexed.
application.filesystem.limit Maximum number of words to be indexed per file.
application.filesystem.indexing.minlength Minimum length of words to be indexed.
application.filesystem.indexing.maxlength Maximum length of words to be indexed.
application.filesystem.mount.followsymlinks Enables support for symbolic links in mounted directories.
applications.uploads.folder Default path for files uploaded via the UploadServlet.

Actions Section

The Add Folders and Add Files buttons create a new folder, respectively file, in the current directory. Both the folder and file are schema types in Structr, from which other types an inherit. Therefore, the drop-down menu in front of the buttons allows you to specify further which type of folder or file should be created. For instance, for the file Structr already provides the specializations Image, VideoFile, MinifiedCssFile and MinifiedJavaScriptFile which you can select when creating a new file.

IllegalStateException: URI has an authority component

2020-03-31 12:33:56.703 [qtp1327213994-88] WARN  org.eclipse.jetty.server.HttpChannel - /resources/script.js
java.lang.IllegalArgumentException: URI has an authority component
at java.base/sun.nio.fs.UnixUriUtils.fromUri(UnixUriUtils.java:53)
at java.base/sun.nio.fs.UnixFileSystemProvider.getPath(UnixFileSystemProvider.java:103)
at java.base/java.nio.file.Path.of(Path.java:203)
at java.base/java.nio.file.Paths.get(Paths.java:97)
at org.structr.web.entity.AbstractFile.defaultGetFileOnDisk(AbstractFile.java:257)
at org.structr.web.entity.Folder.getFileOnDisk(Folder.java:205)
at org.structr.dynamic.Folder.getFileOnDisk(Folder.java:95)

File Upload

Binary data in form of files can be uploaded to the integrated file system in Structr with a form-data POST request to the upload servlet running on path /structr/upload.

The file to be uploaded has to be put as value for the key file. All other properties defined on the File type can be used to store additional data or link the file directly to an existing data entity in the database.

# example file upload with addional paramter "action" and target directory "parent"
curl --location --request POST 'http://localhost:8082/structr/upload' \
--form 'file=@"/Users/lukas/Pictures/user-example.jpg"' \
--form 'action="ec2947e760bd48b291564ae05a34a3b7"' \
--form 'parent="9aae3f6db3f34a389b84b91e2f4f9761"'

Create and use Let's Encrypt certificates

Name Description
letsencrypt.wait Wait for this amount of seconds before trying to authorize challenge. Default is 300 seconds (5 minutes).
letsencrypt.challenge.type Challenge type for Let’s Encrypt authorization. Possible values are ‘http’ and ‘dns’.
letsencrypt.domains Space-separated list of domains to fetch and update Let’s Encrypt certificates for
letsencrypt.production.server.url URL of Let’s Encrypt server. Default is ‘acme://letsencrypt.org
letsencrypt.staging.server.url URL of Let’s Encrypt staging server for testing only. Default is ‘acme://letsencrypt.org/staging’.
letsencrypt.user.key.filename File name of the Let’s Encrypt user key. Default is ‘user.key’.
letsencrypt.domain.key.filename File name of the Let’s Encrypt domain key. Default is ‘domain.key’.
letsencrypt.domain.csr.filename File name of the Let’s Encrypt CSR. Default is ‘domain.csr’.
letsencrypt.domain.chain.filename File name of the Let’s Encrypt domain chain. Default is ‘domain-chain.crt’.
letsencrypt.key.size Encryption key length. Default is 2048.

Let's Encrypt

letsencrypt.wait Wait for this amount of seconds before trying to authorize challenge. Default is 300 seconds (5 minutes).
letsencrypt.challenge.type Challenge type for Let’s Encrypt authorization. Possible values are ‘http’ and ‘dns’.
letsencrypt.domains Space-separated list of domains to fetch and update Let’s Encrypt certificates for.
letsencrypt.production.server.url URL of Let’s Encrypt server. Default is ‘acme://letsencrypt.org’.
letsencrypt.staging.server.url URL of Let’s Encrypt staging server for testing only. Default is ‘acme://letsencrypt.org/staging’.
letsencrypt.user.key.filename File name of the Let’s Encrypt user key. Default is ‘user.key’.
letsencrypt.domain.key.filename File name of the Let’s Encrypt domain key. Default is ‘domain.key’.
letsencryt.domain.csr.filename File name of the Let’s Encrypt CSR. Default is ‘domain.csr’.
letsencrypt.domain.chain.filename File name of the Let’s Encrypt domain chain. Default is ‘domain-chain.crt’.
letsencrypt.key.size Encryption key length. Default is 2048.

Paths

base.path Path of the Structr working directory. All files will be located relative to this directory.
tmp.path Path to the temporary directory. Uses java.io.tmpdir by default.
database.path Path of the Neo4j db/ directory.
files.path Path to the Structr file storage folder.
changelog.path Path to the Structr changelog storage folder.
data.exchange.path Path to the exchange directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The exchange directory is used by the I/O built-in functions read, write and append.
snapshot.path Path to the snapshot directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The snapshot directory is used by the snapshot() built-in function that allows you to read / write the schema of your application from / to a JSON file.
data.webapp.path Path to the webapp directory. This path is relative to the base path of the Structr installation to prevent access to files outside of the installation directory. The webapp directory is used by the internal web server to serve resource files needed by the Structr UI.

file-import

file-import <source> <target> <mode> <existing> <index>  -  Import files directly from a server directoy.
<source> - Path to a directory on the server.
<target> - Target path in Structr's virtual file system.
<mode> - Whether to copy or move the files into Structr's files directory. Possible values: copy (default), move
<existing> - How to handle files already existing with the same path in Structr. Possible values: skip (default), overwrite, rename
<index> - Whether new files should be fulltext-indexed after import. Possible values: true (default), false

directFileImport

Imports files from a directory in the local filesystem. The files can either be copied or moved (i.e. deleted after copying into Structr), depending on the mode parameter. The existing parameter determines how Structr handles existing files in the Structr Filesystem. The index parameter allows you to enable or disable indexing for the imported files.

Changelog

The file-based changelog can consist of many files. You should make sure the file system can handle the amount of files. Depending on the file system it can happen that no more files can be written even if enough space is available.

Content of Current Folder

Size for files this is the size in bytes, and for folders this is the number of subfiles and folders.
Type the type of the folder or file (for files the filetype is also shown).
Owner the user who owns the file or folder.

Actions Section

Name The name under which the folder is to be mounted into Structr’s virtual file system.
Mount Target The full path to the directory on Structr’s host operating system.
Do Fulltext Indexing If the files should be full text indexed.
Scan Interval(s) The rate at which the mounted directory should be refreshed.
Mount Target Folder Type The Schema Type under which Folders in the directory are to be mounted.
Mount Target File Type The Schema Type under which Files in the directory are to be mounted.
Enabled Checksums List of checksum types which are automatically computed on file creation.
Watch Folder Contents Bidirectional synchronization of the files in the mounted directory.

Built-in Properties

Key Description
Include In Frontend Export Should this file/folder (and all subfiles/-folders) be included in the deployment export.
Is Mounted Is this file/folder mounted from the host file system.
Last Seen Mounted if the folder is not mounted, when was it last mounted.
Use As Javascript Library Is this folder used as a server-side javascript library.
Content Type The content type of the given file.
Don’t Cache Is Structr allowed to cache the given file.

Edit File

The other two parameters, Replace <a data-id="c535223d2c1e409ebdcbbfcf1479c15f" class="mention">template</a> expressions and Show preview, are used to configure so-called dynamic files. Additionally to storing static content, as in the case of the text file above, Structr also allows you to open a scripting context within a file and thus inject dynamically generated content. Such files, containing dynamically generated content, are referred to as dynamic files.

To mark a file as a dynamic file, you have to set the parameter Replace <a data-id="c535223d2c1e409ebdcbbfcf1479c15f" class="mention">template</a> expressions. This instructs Structr to evaluate the file as a script, instead of rendering it’s content statically. If you configure a file to be a dynamic file, the Show preview parameter allows you to render a preview of the dynamically generated content.

UploadServlet

uploadservlet.allowanonymousuploads Allows anonymous users to upload files.
uploadservlet.maxfilesize Maximum allowed file size for single file uploads. Unit is Megabytes
uploadservlet.maxrequestsize Maximum allowed request size for single file uploads. Unit is Megabytes

DeploymentServlet

deploymentservlet.allowanonymousdeployments Allow anonymous users to trigger a deployment process.
deploymentservlet.allowanonymousuploads Allow anonymous users to upload deployment files.
deploymentservlet.maxfilesize Maximum allowed file size for single file uploads. Unit is Megabytes.
deploymentservlet.maxrequestsize Maximum allowed request size for single file uploads. Unit is Megabytes.