-
Notifications
You must be signed in to change notification settings - Fork 4
Workflow example: Webhook file receive
Dominick Peluso edited this page Sep 30, 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?filename="myFile.pdf"
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 " +
Object.keys(webhookJob.getUrlParameters()).length + " parameters."
);
webhookJob.getDataAsFileJob(function(fileJob){
fileJob.rename(webhookJob.getUrlParameter("filename"));
fileJob.move(af.createFolderNest("/Users/dominickpeluso/Desktop/Proofs Out/"));
});
});