title: How to post an jpeg image to Facebook me/staging_resources?
body: <p>I'm trying to upload a jpeg image to me/staging_resources by doing something similar to what curl does:</p>
  
  <pre><code>curl -X POST \
    https://graph.facebook.com/me/staging_resources \
    -F "file=@images/prawn-curry-1.jpg" \
    -F "access_token=$USER_ACCESS_TOKEN"
  </code></pre>
  
  <p>The above is from Facebook doc (<a href="https://developers.facebook.com/docs/opengraph/using-object-api/#staging" rel="nofollow">https://developers.facebook.com/docs/opengraph/using-object-api/#staging</a>).</p>
  
  <p>My HTTP request looks something like this:</p>
  
  <blockquote>
    <p>METHOD: POST</p>
    
    <p>HEADERS:</p>
    
    <p>Content-Type    multipart/form-data;boundary=Random_Boundary_Chars</p>
    
    <p>BODY:</p>
  
  <pre><code>--Random_Boundary_Chars
  Content-Disposition: form-data; name="access_token"
  
  USER_AUTH_TOKEN
  
  --Random_Boundary_Chars
  Content-Disposition: form-data; name="file"
  Content-Type: image/jpeg
  Content-Transfer-Encoding: base64
  </code></pre>
    
    <p>/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAABAAEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9/KKKKAP/2Q==</p>
  
  <pre><code>--Random_Boundary_Chars--
  </code></pre>
  </blockquote>
  
  <p>The problem is I'm always getting this response from the server: </p>
  
  <blockquote>
    <p>"WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "(#100) Invalid file. Expected file of one of the following types: image/jpg, image/jpeg, image/gif, image/png" ".</p>
  </blockquote>
  
  <p>In what format should I attach the image to the HTTP request? (I've tried encoding it base64 and also tried using an URL encoder).</p>
  
  <p>Thanks</p>