-
Notifications
You must be signed in to change notification settings - Fork 380
Description
I tried to use the getBuffer function detail here
https://github.com/form-data/form-data#buffer-getbuffer
to get my from as buffer for axios but i end up with an error. I tried to reproduce with the smallest possible code (the issue is when the getBuffer method is call):
const fs = require('fs');
// To add image to post
var FormData = require('form-data');
var formData = new FormData();
// Fill the formData object
formData.append('dum', 'dum');
// load picture image
formData.append('my_file', fs.createReadStream('/tmp/CatWorried1.jpg'));
var aBuff=formData.getBuffer();
I have the following error when calling this code
[root@cc1b78c1db72 myapp]# npm start
[email protected] start /myapp
node index.jsbuffer.js:219
throw new ERR_INVALID_ARG_TYPE(
^TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object
at Function.from (buffer.js:219:9)
at FormData.getBuffer (/myapp/node_modules/form-data/lib/form_data.js:328:57)
at Object. (/myapp/index.js:12:20)
at Module._compile (internal/modules/cjs/loader.js:777:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
at internal/main/run_main_module.js:17:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-18T20_32_47_733Z-debug.log
I tried to debug without success and had a look on the existing ticket and only found this one that is related to this function and type #427 but it seems already closed.
I wonder if i miss something or if there a real issue there. any advice to debug would be welcome.