Notification post-backs without multipart

Archived from the Transloadit support forum. Originally posted on November 15, 2010; details may be outdated, see our docs for current behavior. Original thread

Currently, when Transloadit posts a notification back to my server, the notification JSON comes is bundled in a multipart form, with Content-Disposition: form-data.

I’m handling this notification post-back on my server in a CouchDB update handler, which doesn’t currently parse multipart request bodies, so I have to do parse the JSON response out manually, something like:

var boundary = req.headers['Content-Type'].match(/boundary=(.*)/)[1];
var regexp = new RegExp(boundary + '\r\nContent-Disposition: form-data; name=\"transloadit\"\r\n\r\n(.*)');
var notification = JSON.parse(req.body.match(regexp)[1]);

…but I’d prefer to not have to do this messy regexp work (this naive implementation works, but it’s obviously brittle.)

Wondering if it would be possible to create an option so that I can receive a notification as a non-multipart form? Afaik, the multipart is unnecessary here, given that the notification POST only contains one field that returns JSON.

Ideally, Transloadit would POST to me the JSON in the request body as Content-Type: application/json, so that my web server can intelligently parse out the JSON for me. No need to package this in a form field named “transloadit” if there are no other fields.

…or if the “transloadit” field was necessary, it could be specified in the JSON response body:

{
  "transloadit: {
      "ok": "ASSEMBLY_COMPLETED",
      // etc.
  }
}

Hey Geoff, would sending the POST as urlencoded form data also work for you?

Sure, that would work just fine.

Alright, I think urlencoded PSOTs would work for the majority of users, so I’ll switch to thode. I’ll update this ticket when I deploy this change (should be very soon).

Great, looking forward to this change.

Hey Geoff,

sorry this took a little longer. I have just deployed the change that will cause all of our notifications to be send as application/x-www-form-urlencoded. Let me know if that makes things easier for you!

--fg

Works great, thanks, Felix!