I think that if all of your users are logged in to both Discourse and Nextcloud then it should be possible for a theme component to upload files to nextcloud and insert the URL. This broken theme component used to do that for youtube/vimeo.
Since users are assured to be logged in to both sites then I think it should’t be possible, though it’s not something I’ve done.