title: uploading text blob as file using $http or $resource with angular.js - mimicking curl style multipart/form upload
body: <p>So I need to: upload a text blob as a file using $http or $resource with angular.js  - mimicking curl style multipart/form upload.</p>
  
  <p>There is a <a href="https://stackoverflow.com/questions/33968401/how-to-use-docverter-in-angularjs-nodejs-to-convert-generated-html-to-pdf-for-do">previous post on this problem</a> i'm going to try to be more explicit about the issue with hopes that someone can identify where I may be going astray.</p>
  
  <p>Here is an example of the curl command that I know works with this service:</p>
  
  <pre><code>curl \
  http://c.docverter.com/convert \
  -F from=markdown \
  -F to=pdf \
  -F input_files[]=@&lt;(echo hello) #or @example.md for a file
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/33968401/how-to-use-docverter-in-angularjs-nodejs-to-convert-generated-html-to-pdf-for-do">previous post on this problem</a></p>
  
  <p>example successful log response from sinatra</p>
  
  <pre><code>{"input_files"=&gt;[{:filename=&gt;"api.md", :type=&gt;"text/markdown", :name=&gt;"input_files[]", :tempfile=&gt;#&lt;Tempfile:/tmp/RackMultipart20160426-3-5tb8po&gt;, :head=&gt;"Content-Disposition: form-data; name=\"input_files[]\"; filename=\"api.md\"\r\nContent-Type: text/markdown\r\n"}], "from"=&gt;"markdown", "to"=&gt;"pdf"}
  </code></pre>
  
  <p><strong>On to what I need to do</strong></p>
  
  <p>I need to upload markdown text (I assume using a blob) as a "file" - I have tried both $resource and $http with a dozen different configurations and no luck.</p>
  
  <p>A typical miserable log response after my hundredth angular attempt:</p>
  
  <pre><code>{"from"=&gt;"markdown", "input_files"=&gt;["{}"], "to"=&gt;"pdf"}
  </code></pre>
  
  <p>code example: </p>
  
  <pre><code>angular.module('app')
    .factory('convert', function ($resource) {
      return $resource('http://c.docverter.com/convert', null, {
      pdf: {
        method: 'POST',
        headers: { 'Content-Type': 'multipart/form-data' },
        params: {
          from: 'markdown',
          to: 'pdf',
          'input_files[]': new Blob(['##title'], 'text/markdown')
        }
      }
    });
  });
  </code></pre>
  
  <p>This is really only one example of what i've tried.  I've been hammering at this for a few hours and haven't had much luck so, perhaps someone on here knows more about multipart form data and can shed some light on the pitfalls of blobs and angular.</p>