29.2.6. Files and directories

This section covers the details of the BASE file system.

Figure 29.7. Files and directories

Files and directories

The DirectoryData class holds information about directories. Directories are organised in the ususal way as as tree structure. All directories must have a parent directory, except the system-defined root directory.

The FileData class holds information about a file. The actual file contents is stored on disk in the directory specified by the userfiles setting in base.config. The internalName property is the name of the file on disk, but this is never exposed to client applications. The filenames and directories on the disk doesn't correspond to the the filenames and directories in BASE.

The url property is used for file items which are stored in an external location. In this case there is no local file data on the BASE server.

The location property can take three values:

The md5 property can be used to check for file corruption when a user re-uploads a file that has been offline.

BASE can store files in a compressed format. This is handled internally and is not visible to client applications. The compressed and compressedSize properties are used to store information about this. A file may always be compressed if the users says so, but BASE can also do this automatically if the file is uploaded to a directory with the autoCompress flag set or if the file has MIME type with the autoCompress flag set.

The FileServerData class holds information about an external file server. If the connectionManagerFactory isn't set BASE automatically selects a factory based on the URL of the file. There is built-in support for HTTP and HTTPS, but it is possible to install extensions for support for other protocols. The host property can be set to override the host part of the URL from the file. See Section 27.8.8, “Connection managers” for more information about connection managers.

The username and password properties are used if the server requires the user to be logged in. BASE has built-in support for Basic and Digest authentication. The serverCertificate can be used with HTTPS servers that uses a non-trusted certificate to tell BASE to trust the server anyway. In most cases, this is only needed if the server uses a self-signed certificate, but could, for example, also be used if a trusted site has forgot to renew an expired certificate. The server certificate should be an X.509 certificate in either binary or text format. The clientCertificate and clientPassword properties are used for servers that require that users present a valid client certificate before they are allowed access. The client certificate is usually issued by the server operator and must be in PKCS #12 format.

The FileTypeData class holds information about file types. It is used only to make it easier for users to organise their files.

The MimeTypeData is used to register mime types and map them to file extensions. The information is only used to lookup values when needed. Given the filename we can set the File.mimeType and File.fileType properties. The MIME type is also used to decide if a file should be stored in a compressed format or not. The extension of a MIME type must be unique. Extensions should be registered without a dot, ie html, not .html.