-
Notifications
You must be signed in to change notification settings - Fork 4
Workflow example: Webhook file receive
Dominick Peluso edited this page Oct 28, 2016
·
6 revisions
This workflow creates a webhook which accepts binary data. The workflow creates a new job from this data and saves it to a file in a local folder. The filename of the file is taken from a query string parameter.
POST http://localhost:8081/hooks/proof/upload
var Antfarm = require('antfarm'),
af = new Antfarm({port:8081});
var webhook = af.createWebhookNest(["proof", "upload"], "post");
var tunnel = af.createTunnel("Proof uploading workflow");
tunnel.watch(webhook);
tunnel.run(function(webhookJob){
console.log(
"Received a webhook request! Found " +
webhookJob.getParameters().length + " parameters."
);
webhookJob.getFormDataFiles(function(files){
files.forEach(function(fileJob){
fileJob.move(af.createFolderNest("/Users/dominick/Desktop/Proofs Out/"));
}
});
});