29.2.7. Files and directories

This section covers the details of the BASE file system.

UML diagram

Figure 29.8. Files and directories

Files and directories

Description

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:

  • 0 = The file is offline, ie. there is no file on the disk

  • 1 = The file is in primary storage, ie. it is located on the disk and can be used by BASE

  • 2 = The file is in secondary storage, ie. it has been moved to some other place and can't be used by BASE immediately.

  • 3 = The file is an external file whose location is referenced by the url property. If the file is protected by passwords or certificates the file item may reference a FileServerData object. Note that an external file in most cases can be used by client applications/plug-ins as if the file was stored locally on the BASE server.

The action property controls how a file is moved between primary and seconday storage. It can have the following values:

  • 0 = Do nothing

  • 1 = If the file is in secondary storage, move it back to the primary storage

  • 2 = If the file is in primary storage, move it to the secondary storage

The actual moving between primary and secondary storage is done by an external program. See the section called “Secondary storage controller” and Section 26.6.2, “Secondary file storage plugins” for more information.

The md5 property can be used to check for file corruption when it is moved between primary and secondary storage or 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. The username and password properties are used if the server requires the user to be logged in. BASE supports 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.