I have a file in memory (buffer) - there is no file in the file system. I want to send this buffer to another server that reports HTTP.
For example, some API A creates a file in memory, SignServer manipulates such files and responds with a new buffer. My API takes a file from A and passes it to SignServer.
I tried to send the file to SignServer in several ways, but it continues to respond with a status of 400 (the missing "data" field in the request).
What I tried:
var http = require('http');
var querystring = require('querystring');
var data = querystring.stringify({
workerName: 'PDFSigner',
data: file_buffer
});
var request = new http.ClientRequest({
hostname: 'localhost',
port: 8080,
path: '/signserver/process',
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
});
request.end(data);
I tried to print dataand it showed:
workerName = PDFSigner & data =
, data file_buffer.
file_buffer, ( null, undefined, ).
, .
request, .
, SignServer Node JavaScript. Java, , , json ( querystring). , json.