@liviutudor @dodnert
Bear in mind that the TON API is used for many things, not just TA list uploads. It’s a generic API for simple blob storage used by a number of products both internal and external to Twitter. This is unfortunately also why error messages from this API are a bit obscure and difficult to decipher.
The X-TON-Expires header is only required on some buckets and the documentation you’re referring too is generic in purpose and meant for the TON API in general. For the ta_partner bucket we do always require the X-TON-Expires header. In our example script on GitHub we always set the X-TON-Expires header and this is considered a safe practice since buckets that don’t require the header will simply ignore it.
Regarding case-sensitivity of this header, per the HTTP/1.1 spec (RFC2616) all HTTP headers are always case-insensitive:
Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
As noted already, Content-Type can never be set to application/x-www-form-urlencoded for any bucket and all requests with this value will always be rejected. While the ta_partner bucket accepts all other valid MIME types, some select TON API buckets do place additional restrictions on the Content-Type values allowed.
While the docs do need to remain generic and multi-purpose since this is a separate API used by many things, what would be useful is a table with each bucket, whether or not the X-TON-Expires header is required and the Content-Type values each bucket will accept.
There’s no minimum size required for multi-part uploads, but the maximum size for a single chunk PUT request is 64MB (however, we recommend using a smaller chunk size like 32MB for better results). You could indeed only implement the multi-part upload and for smaller file sizes and just do the initial POST request followed by a single PUT chunk request with the correct byte size specified.
The truth is though, as you’re both experiencing now, the TON API is a bit difficult to get the hang of when you’re first starting out and notorious for being a less-than-friendly interface for developers to work with. In the long run, you’ll likely see us move away from this as a solution and towards more developer-friendly APIs (eg. something like a batch upload for TA lists).