This is needed because `require()` means something different in webpack - it ends up importing the module as something we didn't expect (and is occasionally async)
We use `export default` begrudgingly here. Ideally we'd use just `export`, though this entire SDK expects things to be exported as a default. Instead of breaking everything, we'll sacrifice our export pattern for a smaller diff - a later commit can always do the default export -> regular export conversion.
This is a bit of a mess of passing promises around - we weren't
taking the right promise to pass to cancelUpload.
Also e2e uploads take time to read into memory & encrypt, so allow
cancelling them during those phases too, even though we can't abort
those phases before they're done - we do mark the upload as cancelled
though so filter the current uploads for cancelled ones.
Fixes https://github.com/vector-im/riot-web/issues/4891
Also fairly significant refactor of the uploading code: there are
a number of different ways of triggerring a file upload and each
went through a different code path (the media config size limit
worked on one of those paths). Basically take a lot of code out
of the views and put it into ContentMessages.
Sorry about the size of this patch.
https://github.com/vector-im/riot-web/issues/7565
This allows Webpack to insert the proper image URL after builds steps like
adding a hash and so on. The path you supply to `require` is relative to the JS
source file, just like any other would be.