Set 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.Upload action
Self for chaining
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).
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.
Self for chaining
Set a callback function that is used to remove files which no longer have a reference in a source table.
Table field to be used for the delete match
Self for chaining
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.
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).
Self for chaining
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.
Knex WHERE condition
Self for chaining
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 Field.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 {@link Editor.leftJoin()} for example) and the file on the file system for direct web access.