title: upload image binary - using imageshack api
body: <p>Moving a topic from google groups to here so it can help someone who is asking.</p>
  
  <p>imageshack api: <a href="http://api.imageshack.us/" rel="nofollow">http://api.imageshack.us/</a></p>
  
  <p>the final http reqeust is returning json:</p>
  
  <pre><code>{"success":true,"process_time":325,"result":{"max_filesize":5242880,"space_limit":52428800,"space_used":0,"space_left":52428800,"passed":0,"failed":0,"total":0,"images":[]}}
  </code></pre>
  
  <p>which is not good, as it didn't upload :(</p>
  
  <p>it should return an image object. <a href="http://api.imageshack.us/#h.ws82a1l6pp9g" rel="nofollow">http://api.imageshack.us/#h.ws82a1l6pp9g</a>
  as this is what the upload image section on the imageshack api says</p>
  
  <p>please help :(</p>
  
  <p>my extension code</p>
  
  <pre><code>var blobUrl;
  var makeBlob = function () {
          bigcanvas.toBlob(function (blob) {
                  var reader = new window.FileReader();
                  reader.readAsBinaryString(blob);
                  reader.onloadend = function () {
                          blobBinaryString = reader.result;
                          blobUrl = blobBinaryString;
                          Cu.reportError(blobUrl);
                          uploadBlob();
                  }
          });
  };
  
  var uploadedImageUrl;
  var uploadBlob = function () {
          HTTP('POST', 'https://api.imageshack.us/v1/images', {
                  contentType: 'application/x-www-form-urlencoded',
                  //'album=' + urlencode('Stock History') + '&amp;
                  body: 'auth_token=' + urlencode(auth_token) + 'file@=' + blobUrl,
                  onSuccess: function (status, responseXML, responseText, headers, statusText) {
                          Cu.reportError('XMLHttpRequest SUCCESS - imageshack uploadBlob\n' + statusText + '\n' + responseText);
                          eval('var json = ' + responseText);
                          uploadedImageUrl = json.direct_link;
                          submitBamdex();
                  },
                  onFailure: function (status, responseXML, responseText, headers, statusText) {
                          Cu.reportError('XMLHttpRequest FAILLLLLLLL - imageshack uploadBlob\n' + statusText + '\n' + responseText);
                  }
          });
  };
  
  
  makeBlob(); //callllll the func
  </code></pre>