This extension adds a file resource.
Extensions installation instructions.
This extension validates file type before downloading file.
You can upload files via FormData.
- defaults — object, any default options. Will be applied to the jobs.
- jobname — object, job declaration
- to — string, default filename. Will be applied if action options doesn't have the
to
option - limit — number, maximum files to be accepted
- accept — array, list of the mime types accepted by this job
- do — array, list of action to be applied to each file
{ 'processor:action': {options}}
— action with its options.
- to — string, default filename. Will be applied if action options doesn't have the
Settings example:
this.file = {
defaults: {
root: this.join('static', 'uploads') // files storage root.
},
test: {
accept: [ 'image/jpeg' ],
do: [
{ 'fs:copy': { name: 'copy', to: '{filename}_{copy}{_#}{ext}' } }
]
}
};
All actions have only two common options: name
and to
.
The following curly bracket variables can be used in the to
option:
- fieldname — field name from form data
- filename — original file name
- ext — original file extension
- name — action name
- year — four digits year
- month — the padded (ex. 01) number, 1-based
- day — the padded number, 1-based
- # — unique file pattern read more about it here
plus any data that particular processor accepts with the files.
All generated file paths and names are sanitized. You can upload files with names in any encoding supported by JavaScript.
- fs — built-in processor with the following methods:
- copy copies file
- move moves file
- delete deletes file
- image — super fast image processor with animated GIF support
For processors methods and options go to processors docs.
Processes the file or files with the job
Request
All files and any other data should be sent as FormData.
- job — job name to use for files
Respond
Depends on the processors used in the job.
License: MIT.