discovery.addDocument nodeJS parameters

I’m having difficulty finding any documentation for functions usable for Watson Discovery’s API for node. The API docs only have sample code for curl and Java for adding docs, updating docs, deleting docs. I did find on this portal (though not tagged with Watson-Discovery ironically) that this method below exists.
I’m wondering if any one can help me understand the metadata and file parameters.
Specifically that my files are in .txt format and I’d like to upload them as .txt rather than json to save me time. Is that possible? And if so, what is the proper way to write the value for the Content-Type key?
Also, with Buffer.from can I use fs.readStream?

Also, does anyone have any sort of link to Watson-Discovery API Documentation for Node?
Thanks
Dan

discovery.addDocument({
environment_id: environIdVar,
collection_id: collectIdVar,
metadata:'{“Content-Type”:”application/json”}’,
file:Buffer.from(“HERE IS MY TEXT”, ‘utf8’)
}, function(err, data) {
if (err) {
return next(err);
} else {
return res.json(data)
}
});

Related:

Leave a Reply