Binary File Naming

RELATED CONTENT

Overview

Binary file naming controls the rules that are applied to the naming convention for binary files such as pictures, movies, and PDF files. This limits the ability to upload binary files to those that comply with a specific file naming convention, such as using a rule that all letters must be lower case. This also allows administrators to ensure that the file naming convention is enforced when binary files are renamed, which can be accomplished with the Image Editor for image binaries and through the folder structure. The Binary File Naming feature is enforced whether Binary Management is enabled or disabled. If Binary Management is disabled, the regex is still used even though the files are published immediately to the production server.

Binary File Naming Panel in Site Settings

Note: The Text Regex field becomes available after entering text in the Binary File Name Regex field during site creation.

About Regular Expressions

Binary File Naming uses regular expressions, often referred to as regex, to control the characters allowed in the naming of a file. A commonly used regular expression in file naming is: [a-z0-9\-_.]*

This particular regular expression allows for the file name to include lowercase letters, numbers 0–9, hyphens, underscores, and periods. All other characters are disallowed and present the user with a warning message.

Note that just as with non-binary file naming, certain characters are automatically excluded from OU Campus, and cannot be used for any filename, regardless of the custom regex being used. These characters are as follows:

!#$%^&*()[]\/?’”|<>{};:,+=

Binary File Naming Reference

Binary File Name Regex: A regular expression (regex) can be input into this field to have binary files conform to a file naming convention. Regular expressions allow specification of whether or not letters, numbers, capitalization, etc., are allowed for binary file naming. A commonly used regex allows for lowercase letters, numbers, hyphens, underscores, and periods. The syntax is: [a-z0-9\-_.]*

Binary File Name Must NOT Match: When this is selected, the regex placed in the Binary File Name Regex field indicates that the characters are not allowed in the naming of a file.

Binary Regex DescriptionThe description is shown in addition to the standard error message. This is displayed during file upload via the WYSIWYG Editor, Source Editor, and the folder structure if the uploaded content does not conform to the defined regex.

Test Regex: The Binary File Name Regex field allows the administrator to test the configured regex to make sure that it is preventing the correct characters. The name of a file can be entered here and on-screen a green checkmark or red highlighting indicates the pass or fail status for the test.

Binary File Naming Tutorial

The following provides an example for the use of Binary File Naming to restrict file names to use only lowercase letters, numbers, hyphens, underscores, or periods.

To set up the Binary File Naming regular expression:

  1. Navigate to Setup > Sites, hover and from the Edit menu for the site, click Site.
  2. In the Binary File Naming panel, enter the following regex described in the Binary File Name Regex field: [a-z0-9\-_.]*
  3. Complete the fields for the Binary File Naming panel as follows:
    • In the Binary File Name Regex field enter: [a-z0-9\-_.]*
    • Ensure that the checkbox for Binary File Name Must NOT Match is not selected.
    • In Binary Regex Description, enter a user message. This example uses the text: “Use lowercase letters, numbers, hyphens, underscores, and periods only.”
  4. In Test Regex field, enter an example file name to test the regex syntax. In this example, a file name using lowercase letters, numbers, hyphens, underscores, and periods receives the green checkmark.Binary File Naming Test
  5. Test by enter a name using uppercase letters and a red X indicates the error.Binary File Name Fail
  6. After completing the necessary fields, click Create or Save.

Error Examples

Below are some commonly experienced messages when trying to upload a file with an incorrect naming convention. Keep in mind that the message may be slightly different depending on the site’s settings. These examples utilize the regex that was used for the tutorial that is intended to restrict file names to use only lowercase letters, numbers, hyphens, underscores, or periods: [a-z0-9\._-]*

With Upload

There are three types of available upload options when uploading from the file structure: Standard, Upload and Edit, and Zip Import.

Standard Upload

When performing a standard Upload, if the file name contains illegal characters, the upload is disallowed and the error is shown in red. The description configured with the Binary Regex Description field is also shown. 

To replicate the error:

  1. Navigate to the Pages list view where the binary is to be uploaded.
  2. Click the Upload icon.
  3. Drag a file with uppercase characters in the file name to upload it.
  4. Click Start Upload.
  5. Note the error message.Binary File Naming Error
  6. Click Rename & Retry, remove the file from the modal by hovering over the file name and clicking Rename, renaming the file in your computer file browser, and upload it again.
    Revert Button
  7. Click Start Upload to upload the file.

Upload Done

Zip Import

The second type of upload is Zip Import

If illegal characters exist in the file name of a file or files, the warning message is shown in the Zip Selection section area.

Users can navigate to any file containing illegal characters, and correct the errors by clicking on the file name and updating it to meet the necessary criteria.

The Extract button is dimmed until all file naming issues are resolved.

Upload WYSIWYG Editor

When a regex has been defined for binary file naming to restrict file names to a specific file naming convention, this functionality is also used by the Insert/Edit Image feature of the WYSIWYG Editor.

During Rename

If attempting to rename a file from the Pages list view, any attempted rename that does not match the regex will trigger an error message like the one below.

Error Notification