Introduction to Media Types
This document describes the basic data model for Media-iBox 2 and Media-iBox API (which is the core of Media-iBox 3).
In this document, structures that are obsolete or only used in narrow cases won’t be included. Default data structures only used for relations (such as N:N relationship tables) will also be omitted so as to simplify understanding.
Media Type
“Media Type” is how a table that can be manipulated through Media-iBox 3 CMS or Media-iBox API is called. A record inside such table is called a “Media-iBox Object” (“MibObject”).
All Media Types (i.e. any table that can be exposed through the CMS) must consist in its most basic structure of the following data model:
Mandatory Columns
ID: int, autoincremented, not null, PK- Unique identifier for the record.
DATEINS: datetime, default getdate(), not null- Creation date for the record.
- Currently in local time, but there are plans to convert it to UTC.
NAME: varchar, not null- Internal name for record.
- Must NOT be exposed outside the CMS. A convention typically used is to create a second TITLE column for the name used outside the CMS.
OWNER: int, not null, relation to ADM_USERS.ID- ID of the user that created this record. Used by the permission model, described later in the document.
Optional Columns
MIB_LAST_UPDATE: dateins, null- If present, this column will be updated with the current date any time the object is modified in the CMS/API.
SOURCE: int, null, relation to SOURCES.ID- Content Source (“Category”) for this record. Used by the permission model, described later in the document.
File Media Type
A Media Type can represent files and medias (documents, images, audios, videos) and allow upload/download behavior in their respective form page in Mib CMS. The handling of files through a CMS form page depends on proper integration with either one of these services:
- (Mib Version < 6.0) Mib Api
- (Mib Version >= 6.0) Mib Api + File Management Service
- DMM
Given that you are all set with these integrations, the next thing to do is to make sure that your Media Type meets the two following requirements:
- The Media Type should include all mandatory columns described below in addition to the ones mentioned in the previous section (see). These columns are filled out automatically, so if exposed via ADM_FIELDS, they can be described as readonly.
- The Media Type should be linked with at least one file extension via the meta Media Type ADM_FILEEXTENSIONS.
Mandatory Columns
FILENAME: varchar, not null- Original filename/foldername of the data BEFORE upload. Will NOT correspond to the filename in the storage.
EXT: varchar, not null- Extension of the original file, including the “dot”. Will be saved as “FOLDER” if this record correspond to a group of files, such as a DASH media.
FILESIZE: bigint, not null- Total size of the files represented by this record.
STORAGEAREA: int, not null- Unique identifier of the storage area the files in this record is saved to.
SUFFIX: varchar, not null- Randomly generated suffix for the file/folder in the storage. Used to make the path to each file in the storage non-”guessable”.
RELATIVE_URL: varchar, not null- Relative path to the file inside the storage.
Optional Columns
HEIGHT: integer, null- The height metadata of an image
WIDTH: integer, null- The width metadata of an image
UPLOAD_COMPLETE: integer, null- After the succesful upload of the underlying file, this column is set value "1"
There are some default tables distributed with Mib that have been built with this structure. One example is the media type IMAGES, which refers to files stored in the system.
Storage Area
Media-iBox supports multiple storage areas in the same installation. Different Storagea Areas can be configured depending on the underlying service being used for the upload/download of the files (which has been mentioned here)
A storage area corresponds to a folder/bucket in either:
- Local File System
- NAS
- Amazon S3
- Azure Blob
- ... (please refer to the documentation of the respective service that is handling the file for preciser information)
You can mix different storage area types in the same installation - it’s possible to have smaller files stores in the local disk and larger media files in S3.
Files will be stored in the final location using the following directory path pattern:
/<MEDIA_TYPE>/<SUB_FOLDER>/<ID>_<SUFFIX>
Where:
MEDIA_TYPE Name of the media type being persisted (i.e. table name).
SUB_FOLDER The subfolder is a segmentation of the files/folders in groups of 10000, done to avoid having too many files in the same folder, which causes issues with some management tools. This is done by formating the ID with ten digits, taking the first six, then breaking down in groups of two. As an example, if the ID for this particular file is “9347123“, the folder where it’ll be stored will be:
9347123 -> 0009347123 (Formatted as 10 digits) -> 000934 (First 6 Digits) -> /00/09/34 (Subfolder)
ID Unique identifier of the mib object
SUFFIX A randomly generated identifier, for example “8C5E30A1135C35D8”.
For example, let’s suppose we upload a JPG file from the IMAGES media type form page, which was assigned the ID "9347123" and the random suffix “8C5E30A1135C35D8”. The final path for this file in the storage will be:
/IMAGES/00/09/34/9347123_8C5E30A1135C35D8.jpg
Additional Remarks about Media Types
The Media-iBox .NET APIs do NOT make a distinction between “null” and “empty” fields. This applies to all data types.
In case the field is NULL, it’ll be internally treated as:
- Numeric Fields (int, long, float, double) -> Zero
- Text Fields (varchar, nvarchar, text) -> Empty String
- Date Fields (datetime, datetimeoffset) -> DateTime.MinValue
While it’s possible to work around this, it’s recommended to avoid create data models that treat NULL differently from those values when using Media-iBox.