OK. I’m still not 100% sure, what’s going on. First: I’m not experienced with CDN and I normally use only images, so I didn’t test my approaches with pdf and other files, yet. You might have to adjust a few things.
I wrote a cli command to import a complete folder structure recently. Maybe it helps to get started.