I ran into a similar problem when reading in a file in Node as a byte of a byte array and sending it to Rekognition.
I solved it instead of reading in the base64 view, and then turned it into a buffer like this:
const aws = require('aws-sdk');
const fs = require('fs');
var rekognition = new aws.Rekognition({
apiVersion: '2016-06-27'
});
// pull base64 representation of image from file system (or somewhere else)
fs.readFile('./test.jpg', 'base64', (err, data) => {
// create a new buffer out of the string passed to us by fs.readFile()
const buffer = new Buffer(data, 'base64');
// now that we have things in the right type, send it to rekognition
rekognition.detectLabels({
Image: {
Bytes: buffer
}
}).promise()
.then((res) => {
// print out the labels that rekognition sent back
console.log(res);
});
});
, : Expected params.Image.Bytes to be a string, Buffer, Stream, Blob, or typed array object.