title: Posting a Base64-encoded image file to Slack channel from slackbot
body: <p>At this point in my code, I've got an <code>img</code> variable which contains a base-64-encoded image. I've confirmed that the base-64 image is correct by logging <code>img</code> and pasting the output into the code beautify base-64 image encoder.</p>
  
  <p>Now, I'm trying to figure out how to POST to the Slack API. I've read the files.upload method API documentation for Slack, which says they accept multipart form data or application/x-www-form-urlencoded, but I don't know how to convert from Base-64 to either of those from node.js. Once I've done the conversion, I also don't know how to make the actual post using request.post, as it's unclear to me how to encode the relevant information for the slack request.</p>
  
  <p>Currently, I'm trying something like this:</p>
  
  <pre><code>        request.post({ url: 'https://slack.com/api/files.upload',
            formData: {
              token: slackToken,
              tile: "Image",
              filename: "image.png",
              filetype: "auto",
              channels: "testing",
              file: img,
            },
          }, function (err, response) {
              // just for debugging
              console.log(JSON.parse(response.body));
          });
  </code></pre>
  
  <p>Getting response: 
  <code>{ ok: false, error: 'no_file_data' }</code>, which makes sense, as Slack does not accept base-64 encoding of <code>img</code></p>
  
  <p>Any help much appreciated!</p>