Skip to content

Add support for file uploads

Legoktm requested to merge upload into main

The main difference from normal requests is that uploads require sending files in multipart requests. These requests are also generally not retriable since it might be referring to a Stream (not yet implemented) that can't be cloned. The logic of making requests has been extracted so it can be called independently.

As part of this refactor, we had to move the retry-after header handling into the error itself. Unfortunately this is a breaking change since it changes the error types, so we can make a few other changes like replacing should_retry() with retry_after().

By default, files are uploaded in chunks of 5MB. This can be adjusted depending on the wiki you're uploading to and bandwidth. If the wiki supports it, async mode will be used too. Upload-by-url is not supported yet, mostly because the MediaWiki implementation is pretty busted and you're better off downloading it on your own.

Bug: T319098

Merge request reports