In order to support storing and fetching file resources from/to external locations Moodle offers Repositories. In case you need it is possible to develop custom repository plugin.
https://docs.moodle.org/dev/Repository_plugins
Before you go that route I suggest to check if there is anything already available to suit your needs
https://moodle.org/plugins/?q=type:repository
General developer forum
File upload to external server-storage
This discussion has been locked so you can no longer reply to it.