Uploading binary/multipart file with Tesla to AWS S3

For anyone who’s curious about this.

transfer-encoding: chunked is the is automatically added as a header when an adapter (such as Hackney) doesn’t know the size of the upload, aka content-length is not set.

In this case I think the multipart upload isn’t setting the length.

Instead of a multipart upload I’d suggest putting the filename in the signed url and then adding the content-type as a header.

If you need to upload a file larger than 2GB there’s a special way to do that – don’t chunk it.

For the above code the fix is to:

  • include the name in the signed upload URL, not a form post
  • put the entire file in the body
  • set the content-type as a header, probably using the MIME hex package to determine the mime type from the file extension.