transloadit

Node.js SDK for Transloadit

Transloadit NodeJS SDK

This is the official node.js SDK for Transloadit. It's been provided by the founders but everybody is encouraged to suggest ideas or code for improvement.

Inside your project, type

npm install --save transloadit

If there are no errors, you can start using the module.

var TransloaditClient = require('transloadit');
var transloadit       = new TransloaditClient({
  authKey    : 'YOUR_AUTH_KEY',
  authSecret : 'YOUR_AUTH_SECRET'
});
 
transloadit.addFile('file1', filePath);
var assemblyOptions = {
  params: {
    template_id: 'YOUR_TEMPLATE_ID'
  }
};
transloadit.createAssembly(assemblyOptions, function(errresult) {
  if (err) {
    throw new Error(err);
  }
 
  console.log('success');
 
  var assemblyId = result.assembly_id;
  console.log({
    assemblyId: assemblyId
  });
 
  transloadit.deleteAssembly(assemblyId, function(err) {
    console.log('deleted');
  });
});

These are the public methods on the TransloaditClient object and their descriptions.

Returns a new instance of the client. The options object must at least include authKey and authSecret keys (and their values).

You can also provide service, which defaults to "api2.transloadit.com", and region, which defaults to "us-east-1".

Calculates a signature for the given params JSON object. If the params object does not include an authKey or expires keys (and their values) in the auth sub-key, then they are set automatically.

This function returns an object with the key signature (containing the calculated signature string) and a key params, which contains the stringified version of the passed params object (including the set expires and authKey keys).

Registers the local file with the client. The next call to createAssembly will upload that file.

Registers the provided stream with the client. The next call to createAssembly will upload that stream.

Creates a new assembly on Transloadit, uploading all streams and files that were registered via .addStream() and .addFile() prior to the call to .createAssembly().

You can provide some options:

  • params - an object containing your template_id, notify_url, some steps that overwrite your Transloadit template and other params to control Transloadit behavior.
  • fields - an object of form fields to add to the request, to make use of in the assembly via assembly variables.

Returns the internal url that was used for the last call to Transloadit.createAssembly(). This is meant to be used for debugging purposes.

Retrieves an array of assemblies according to the given params.

Valid params can be page, pagesize, type, fromdate and todate. Please consult the Transloadit API docs for details.

Retrieves the JSON status of the assembly identified by the given assemblyId.

Removes the assembly identified by the given assemblyId from the memory of the Transloadit machines, ultimately cancelling it. This does not delete the assembly from the database - you can still access it on https://transloadit.com/assemblies/{assembly_id} in your Transloadit account. This also does not delete any files associated with the assembly from the Transloadit servers.

Replays the assembly identified by the given assembly_id. The options parameter must contain an assembly_id key containing the assembly id. Optionally you can also provide a notify_url key if you want to change the notification target.

Replays the notification for the assembly identified by the given assembly_id. The options parameter must contain an assembly_id key containing the assembly id. Optionally you can also provide a notify_url key if you want to change the notification target.

Retrieves an array of assembly notifications according to the given params.

Valid params can be page, pagesize, type and assembly_id. Please consult the Transloadit API docs for details.

Creates a template the provided params. The required params keys are: name (the template name) and template (the template JSON string).

Updates the template represented by the given templateId with the new value. The params works just like the one from the createTemplate call.

Retrieves the name and the template JSON for the template represented by the given templateId.

Deletes the template represented by the given templateId on Transloadit.

Retrieves a list of all your templates from Transloadit. The params parameter can contain properties such as order, sort, and page. For a list of all available params please check this entry in the Transloadit API docs.

We'd be happy to accept pull requests. If you plan on working on something big, please first drop us a line!

The SDK is written in CoffeeScript, but the JavaScript it generates is commited back into the repository so people can use this module without a CoffeeScript dependency. If you want to work on the source, please do so in ./src and type: make build or make test (also builds first). Please don't edit generated JavaScript in ./lib!

Check your sources for linting errors via make lint, and unit tests via make test.

Releasing a new version to npmjs.org can be done via make release-major (or minor / patch, depending on the semantic versioning impact of your changes). This will

  • update the package.json
  • save a release commit with the updated version in Git
  • push to Github
  • publish to npmjs.org

Contributions from:

Thanks to:

  • Ian Hansen for donating the transloadit npm name. You can still access his code under v0.0.0.

MIT Licensed.