Node version: v8.11.3
Npm version: 6.4.1
SDK version: 2.335.0
Bytes parameter not recognizing base64 encoded string "image/png;base64,Qk02EA..." and throwing error "InvalidImageFormatException: Request has invalid image format" when i try to make the request.
I also tried with:
They all display the same error. Test case:
let params = {
Image: {
Bytes: 'BASE_64_STRING'
},
};
rekognition.detectFaces(params, function(err, data) {
if (err) {console.log(err, err.stack)}
else console.log(JSON.stringify(data);
});
Can you give an example of how you are setting up the Bytes (or Buffer, Blob, Typed Array)?
This Buffer example should work for you:
const fs = require('fs');
const file = 'foo.jpeg';
const bitmap = fs.readFileSync(file);
const buffer = new Buffer.from(bitmap, 'base64')
let params = {
Image: {
Bytes: buffer
},
};
Could you also try using uploading the same image to the Rekognition Console?
I still get the same error, even with the example that you provided, full log:
{ InvalidImageFormatException: Request has invalid image format
at Request.extractError (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\protocol\json.js:48:27)
at Request.callListeners (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request.<anonymous> (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\request.js:38:9)
at Request.<anonymous> (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\request.js:685:12)
at Request.callListeners (C:\Users\USERNAME\Documents\GitHub\Repositories\PROJECT\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
message: 'Request has invalid image format',
code: 'InvalidImageFormatException',
time: 2018-10-19T17:26:04.207Z,
requestId: '0e14e09a-d3c4-11e8-a55d-XXXXXXXXXXXX',
statusCode: 400,
retryable: false,
retryDelay: 53.60815455763171 }
Does the image work when uploading it to the console?
No it doesn't work, i see the problem is the image, i just tried with another one and it works just fine. Thank you so much!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
Can you give an example of how you are setting up the Bytes (or Buffer, Blob, Typed Array)?
This Buffer example should work for you:
Could you also try using uploading the same image to the Rekognition Console?