« Back to demos index

Processing multiple file types

Our robots are clever folks. They only start their work if their input file has a file type that they expect. This allows you to do several different things with the same assembly instructions.

In the demo below notice how the steps "image_thumbs", "video_thumbs" and "encode_video" all have a value of ":original" for their "use" parameter. Each robot only processes the files it can handle, which means that the image resize robot for example does nothing if the user uploaded a video. The upload will be successfully processed regardless.

Try uploading a video and then an image and notice how the result files differ.

"steps": {
  "image_thumbs":{
    "use": ":original",
    "robot": "/image/resize",
    "format": "png",
    "width": 320,
    "height": 240
  },
  "video_thumbs":{
    "use": ":original",
    "robot": "/video/thumbs",
    "width": 320,
    "height": 240,
    "resize_strategy": "pad",
    "background": "#000000",
    "count": 4
  },
  "encode_video":{
    "use": ":original",
    "robot": "/video/encode",
    "preset": "flash",
    "width": 640,
    "height": 480
  },
  "store":{
    "use": ["image_thumbs", "video_thumbs", "encode_video", ":original"],
    "robot": "/s3/store",
    "bucket": "YOUR_S3_BUCKET",
    "key": "YOUR_AWS_KEY",
    "secret": "YOUR_AWS_SECRET"
  }
}
$(function() {
  $('form').transloadit({
    wait: true,
    autoSubmit: true
  });
});

The form

For demos we allow a maximum of 30MB.

This form is html5-multiupload enabled. If your browser supports it, you can select multiple files and execute the template with them.