title: Flutter: send multipart request to node.js server api
body: <p>I have a Flutter app where users fill a form and add images (upto 5). I want to send this complete data to my node.js server via API.</p>
  
  <p>Here is my flutter code:</p>
  
  <pre><code>List&lt;File&gt; _imageFileList = new List&lt;File&gt;();
  var postUri = Uri.parse('https://myapi.herokuapp.com/api/user/new');
      var request = new http.MultipartRequest("POST", postUri);
  
      request.headers['Authorization'] = 'Bearer ' + prefs.getString("TOKEN");
  
      request.fields['first_name'] = _firstName;
      request.fields['last_name'] = _lastName;
  
      // add file to multipart
      request.files.add(
        new http.MultipartFile(
            'upl',
            new http.ByteStream(DelegatingStream.typed(_imageFileList[0].openRead())),
            await _imageFileList[0].length()
        )
      );
  
      // send
      var response = await request.send();
      print(response.statusCode);
  
      // listen for response
      response.stream.transform(utf8.decoder).listen((value) {
        print(value);
      });
  </code></pre>
  
  <p>On my Node.js app I do the following:</p>
  
  <pre><code>var s3 = new aws.S3();
  
  var upload = multer({
      storage: multerS3({
          s3: s3,
          bucket: 'mybucketname',
          acl: 'public-read',
          key: function (req, file, cb) {
              console.log(file);
              cb(null, file.originalname);
          }
      })
  });
  
  router.post('/new', upload.array('upl'), (req, res) =&gt; {
      var userObj = req.body;
      userObj.uuid = uuidv4();
      User.create(userObj).then(user =&gt; {
          console.log('----- added user: ' + JSON.stringify(user));
          res.status(200).json({
              message : 'user added'
          });
      });
  });
  </code></pre>
  
  <p>The problem is in my API call I do get the first and last name and it gets saved, however I do not receive any image(s). </p>