Static
DbStatic
DbSet the action to take when a file is uploaded. This can be either of:
__EXTN__
- the file extension__NAME__
- the uploaded file's name (including the extension)__ID__
- Database primary key value if the db method is
used.Self for chaining
Upload action
Database configuration method. When used, this method will tell Editor what information you want written to a database on file upload, should you wish to store relational information about your file on the database (this is generally recommended).
Self for chaining
The name of the table where the file information should be stored
Primary key column name. The Upload
class
requires that the database table have a single primary key so each
row can be uniquely identified.
A list of the fields to be written to on upload. The property names are the database columns and the values can be defined by the constants of this class. The value can also be a string or a closure function if you wish to send custom information to the database.
Optional
format: DbFormatFunction that can post process the data fetched from the database.
Set a callback function that is used to remove files which no longer have a reference in a source table.
Self for chaining
Table field to be used for the delete match
Optional
callback: Function = nullFunction that will be executed on clean. It is given an array of information from the database about the orphaned rows, and can return true to indicate that the rows should be removed from the database. Any other return value (including none) will result in the records being retained.
Add a validation method to check file uploads. Multiple validators can be added by calling this method multiple times - they will be executed in sequence when a file has been uploaded.
Self for chaining
Validation function. A files parameter is
passed in for the uploaded file and the return is either a string
(validation failed and error message), or true
(validation passed).
Add a condition to the data to be retrieved from the database. This
must be given as a function to be executed (usually anonymous) and
will be passed in a single argument, the Query
object, to which
conditions can be added. Multiple calls to this method can be made.
Self for chaining
Knex WHERE condition
Generated using TypeDoc
Upload class for Editor. This class provides the ability to easily specify file upload information, specifically how the file should be recorded on the server (database and file system).
An instance of this class is attached to a field using the upload method. When Editor detects a file upload for that file the information provided for this instance is executed.
The configuration is primarily driven through the db and action methods:
Both methods are optional - you can store the file on the server using the db method only if you want to store the file in the database, or if you don't want to store relational data on the database us only action. However, the majority of the time it is best to use both - store information about the file on the database for fast retrieval (using a () for example) and the file on the file system for direct web access.
Export