Notifications vs Redirect Url

This guide assumes that you are familiar with the Transloadit basics and the minimal integration example.

There are two ways you can have Transloadit contact you:

Redirect Url

If you use our jQuery plugin

If you use our jQuery plugin and set its wait parameter to true, the plugin will append the file results to your form as soon as Transloadit has finished processing your files. Then it submits the form to the form's defined action or to the redirect_url if it is present.

{
    auth: {key: "your-auth-key"},
    steps: {...},
    redirect_url: "http://example.org/upload"
}

This has a clear disadvantage, however:

Once the file upload is finished, your users have to wait for Transloadit to finish encoding the videos, resize the images etc. before the form is actually submitted to its final destination. That is not so bad if you only process images as that is really fast in most cases, but for video encoding this is a definite harm on the user experience. In that case you should read up on Notifications below.

If you use the jQuery plugin and set its wait parameter to false, you will have to use Notifications, otherwise there is no way to get the file results from Transloadit.

If you do not use our jQuery plugin

In this case providing redirect_url is mandatory. Transloadit will submit the form to transloadit.com and redirect to your redirect_url. It will also append two GET parameters: assembly_id and assembly_url.

The assembly_id parameter contains the unique id of your assembly. The assembly_url is a transloadit url where you can then fetch the results of the file upload. The result will be in JSON and it will also contain the values of any other form fields that are not related to the file upload.

Notifications

A good way to get the file results is to use notifications. Notifications allow you to give Transloadit a url where it will contact you whenever an assembly / request is completed - that means all uploaded files have been encoded, resized etc.

All notifications come in as POST requests, with a parameter called transloadit. Please read up on Transloadit's response in the api documentation for further details

To use notifications, simply add a notify_url parameter to your params field or your template:

{
    auth: {key: "your-auth-key"},
    steps: {...},
    redirect_url: "http://example.org/upload",
    notify_url: "http://example.org/files_ready"
}

If you use the jQuery plugin

A common use case is to include our jQuery plugin, set its wait parameter to false and use a notify_url. That will submit the form to its action (or the redirect_url if it is present) as soon as the upload has finished, ie it will not wait for the Transloadit results. Transloadit notifies your server with the results when it's done processing the uploaded files.

This yields the best experience for your users as they do not have to wait unnecessarily when uploading files.

Note that when you use our jQuery plugin you have to either provide your destination url directly in the form's action or provide a redirect_url which the plugin will submit your form to. A redirect_url is preferred, however, because otherwise the form will not work without Javascript enabled. This is regardless of whether you use notifications or not.

If you do not use the jQuery plugin

Simply provide a redirect_url where Transloadit will redirect your request to when the upload has finished. It will then notify your server on the given notify_url providing all the file results as well as the values of all form fields unrelated to the file upload. You will not need to query the assembly_url yourself in this case.

Comments