Buffer support for Multipart generation #2

Merged
merged 1 commit into from Mar 5, 2012

2 participants

@dlindahl

I recently needed the ability to accept a Base64 input and immediately pass it on to a 3rd party service.

Rather than writing the data to disk just to send it off and delete it, I added the ability to pass the raw file contents directly to Needle so that it can properly encode the data in its Multipart construction.

This can be done by specifying a buffer attribute (as opposed to the file file path attribute):

var base64_input = new Buffer(form_image_input.replace(/^data:image\/\w+;base64,/, ""), "base64");
var data = {
  foo: bar,
  image: { file: '/home/tomas/linux.png', content_type: 'image/png' },
  gif: { buffer: base64_input, content_type: 'image/gif' }
}
Derek Lindahl Added support for Buffers when generating Multipart messages.
This can be done by specifying a `buffer` attribute as opposed to a `file` attribute.
0ed8651
@tomas
Owner

Looks neat, good job man. I'm merging it but I want to add a few specs before pushing a new release.

@tomas tomas merged commit f36cf4c into tomas:master Mar 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment