title: Posting picture to facebook Graph API using angularjs
body: <p>I try to get the image upload to facebook working... Unfortunately, the facebook graph API always returns the following error:</p>
  
  <pre><code>{ error: Objectcode: 324, message: "(#324) Requires upload file", type: "OAuthException" }
  </code></pre>
  
  <p>It seems that the picture data is not transfered correctly. The facebook docs tell me to use a multipart/form-data upload. (See <a href="https://developers.facebook.com/docs/graph-api/reference/v2.1/user/photos" rel="nofollow">here</a> > Publishing)</p>
  
  <p>I am using <a href="https://github.com/pc035860/angular-easyfb" rel="nofollow">angular-easyfb</a> as a wrapper for the faceebook sdk. What's the easiest way to get this thing working? My current code is:</p>
  
  <pre><code>var sharePhoto = function() {
      ezfb.api("/me/photos",
         "POST",
         {
             "source": content,
             "message": "This is a test Photo"
         },
         function (response) {
             console.log("shared", response);
             if (response &amp;&amp; !response.error) {
                /* handle the result */
             }
         });
  };
  
  ezfb.getLoginStatus(function(response) {
      if(response.status === 'connected') {
          console.log("already conntected", response);
          sharePhoto();
      } else {
          ezfb.login(function(response) {
              // Do something with response.
              console.log("FB",response);
              sharePhoto();
          }, {scope: 'public_profile,email,user_photos,publish_actions'});
      }
  });
  </code></pre>
  
  <p>The console-log is:</p>
  
  <pre><code>already conntected {status: "connected", authResponse: Object} 
  shared {error: {code: 324, message: "(#324) Requires upload file", type: "OAuthException"}}
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li>Whats the expected format of my variable <em>content</em>? How do I need to
  encode it? </li>
  <li>Do I have to manipulate the request Headers of the request? How?</li>
  </ul>
  
  <p>Thanks a lot for your help!</p>
  
  <p><strong>Edit:</strong> Console-Log added</p>