Skip to content

Instantly share code, notes, and snippets.

@webjay
Created February 5, 2015 02:49
Show Gist options
  • Save webjay/66ec31e2264c62e701ac to your computer and use it in GitHub Desktop.
Save webjay/66ec31e2264c62e701ac to your computer and use it in GitHub Desktop.
quoted-printable form part
'use strict';
var mimelib = require('mimelib');
var EOL = '\r\n';
module.exports = formpart;
function escapeQuotation (str) {
return str.replace(/"/g, '\"');
}
function formpart (boundary, name, value) {
var lines = [
'Content-Disposition: form-data; name="' + escapeQuotation(name) + '"',
'Content-Type: text/plain; charset=UTF-8',
'Content-Transfer-Encoding: quoted-printable'
];
var part = '';
part += '--' + boundary + EOL;
lines.forEach(function (line) {
part += mimelib.foldLine(line);
part += EOL;
});
part += EOL;
part += mimelib.encodeQuotedPrintable(value);
part += EOL;
return part;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment