Andrew Pinkham
Andrew Pinkham

Reputation: 630

Errors Uploading Chunked Images to Twitter via OAuth.io

NB: a minimum-viable-example exists here, with text copied from below.

We are unable to reliably upload images to Twitter.

Twitter has a REST API endpoint for uploading chunked images. We are using OAuth.io (documentation here) to interact with Twitter. We are uploading the image as a base64 string.

If we upload an image in a single chunk, then the image uploads to Twitter without any problem. However, if we split the same image into multiple chunks, then Twitter may:

  1. refuse to upload the image, informing us that the Segments do not add up to provided total file size once the FINALIZE command is called;
  2. accept the the image, but display a corrupted image in the tweet.

The error behavior varies based on the individual file used and the chunk size of our upload. However, we have not been able to determine any viable rules to guarantee success, and certain files seem to be more error prone than others.

Without the ability to introspect what OAuth.io is POSTing or what Twitter is receiving, we are unable to determine where the problem may be occurring.

The code to demonstrate this behavior is quite long (~200 lines of JS, not including the base64 images or HTML). I've published a full working example here for people to interact with. The code from the example available on Github.

Upvotes: 2

Views: 377

Answers (0)

Related Questions