Closed ammilanov closed 8 years ago
This should be fixed in v2.9.0, which will be published once the CI loop completes. I used a slight variation of your suggestion to handle buffers, and also made it accept Objects so that you can just specify the filename and/or content type yourself using request's format.
Please try it out and let me know if it works for you.
Feature request
The Visual Recognition library should be able to support
Buffer
objects for the 'classify' operation. So far only fileReadStream
s are supported.One should be able to something like that:
My use case
Consider a file uploaded to a Node web application. Suppose you have the image data and you construct or get somehow a
Buffer
object containing the data. While storing the file onto the disk and creating aReadStream
is an option, it is somewhat complicated and a lot slower in term of performance.Proposed solution
Remove the
isStream
limitation from the following file: https://github.com/watson-developer-cloud/node-sdk/blob/76998c9a340259aead2c0c4ef2807ddaa91fbf67/visual-recognition/v3.js#L55Since the
request
library supportsBuffer
s it should not be that hard. The only complication here is, that currently (version '2016-05-20') the Watson Visual Recognition API counts on the file extension submitted through the HTTP request and not on the MIME type to detect the image format.So a sample call using
request
should look something like that: