I have a file in memory (in a buffer), it doesn't exist on the file system (so I can't just stream that).
I'm trying to send it to SignServer using HTTP.
Here's how I try to do it:
var formdata = require('form-data'); var form = new formdata();
form.append('workerName', 'PDFSigner');
form.append('data', file_buffer);
// or
// escape(file_buffer.toString('binary'))
// or
// file_buffer.toString('binary') (without escaping)
var request = form.submit('http://localhost:8080/signserver/process', function(err, res) {});
When I try appending file_buffer
SignServer says that data
is empty:
Status 400 - Missing file content in upload
When I try appending escape(file_buffer.toString('binary'))
(as suggested in How do I send a buffer in an HTTP request?) it's the same story.
When I try appending file_buffer.toString('binary')
node.js crashes saying:
node: ../src/stream_base.cc:157 int node::StreamBase::Writev(const v8::FunctionCallbackInfo&): Assertion `(offset) <= (storage_size)' failed.
Aborted (core dumped)
How do I correctly send the file (buffer) through HTTP (multipart/form-data) in Node.JS?