
/file/filter robot
The accepts and declines parameters expect arrays with three members:
- A job variable; for example
${file.mime}, or a value - An operator, which is one of the following:
=, <, >, <=, >=, !=, regex - A value; for example
50or"foo", or a job variable
Examples:
['${file.meta.width}', '>', '${file.height}']['${file.size}', '<=', '720']['720', '>=', '${file.size}']['${file.mime}', 'regex', 'image']
See below for a list of supported job variables.
Optional parameters
| Name | Type | Default | Description |
|---|---|---|---|
| use | String or array | The previous step |
Specifies which step to use as the input to this robot. The default is to use the previous step defined above the current one. A special step name is ":original", which "uses" the originally uploaded files.
You can also add arrays here to "use" several steps: "use": [":original", "encode2", "resizing3"]
See a demo for the "use" parameter here. |
| accepts | array | [] |
If at least one requirement matches, the file will be accepted.
If none match, it will be declined. Example:[['${file.mime}', '=', 'image/gif']]
|
| declines | array | [] |
If at least one requirement matches, the file will be declined.
If none match, it will be accepted. Example:[['${file.size}','>','1024']]
|
| error_on_decline | boolean | false |
If set to true the assembly will be stopped and marked with an error
if at least one file was declined.
|
| error_msg | string | "One of your files was declined" |
The error message that will be shown to your users (e.g. in the jQuery plugin)
if a file was declined and error_on_decline is set to true.
|
Available job variables
Important: Conditions on properties that a file does not have, will be ignored. For example an image does not have ${file.meta.bitrate}. Also note that ${file.width} will be ignored. Please use ${file.meta.width}.
| Variable | Description |
|---|---|
| ${account_id} | The id of your Transloadit account. |
| ${assembly.id} | The id of the assembly which represents the current upload processing. |
| ${unique_prefix} | A unique 33 character prefix you can use to avoid file name collisions. Example: "f2/d3eeeb67479f11f8b091b04f6181ad" |
| ${previous_step.name} | The name of the previous step that produced the file currently uploaded by the s3 store robot. |
| ${file.name} | The name of the stored file. |
| ${file.url_name} | The name of the stored file stripped from any characters but: A-Za-z0-9-_.. Spaces are replaced with dashes. |
| ${file.*} |
Any file property that is available in the final results array. For example: "${file.meta.width}". Please check our
meta data documentation for more information.
|
Available operators for the conditions
| Operator | Description | Example |
|---|---|---|
| = | equals | ['${file.ext}', '=', 'jpg'] |
| < | less than | ['${file.size}', '<', '1024'] |
| > | greater than | ['${file.meta.width}', '>', '${file.meta.height}'] |
| <= | less or equal | ['${file.meta.audio_bitrate}', '<=', '256000'] |
| >= | greater or equal | ['${file.meta.audio_samplerate}', '>=', '44100'] |
| != | not equal to | ['${file.ext}', '!=', 'jpg'] |
| regex | regex match, case-insensitive per default | ['${file.mime}', 'regex', 'image'] |
Demos
- Only accept images
- Ignore files that are smaller than 1KB
- Only accept videos and images, and ignore all other file types
- Ignore all audio files that have a bit rate that is less than 64k
- Decline videos that are bigger than 20MB or longer than 5 minutes.