Thank you, @peterg, this seems to very well respond to the OP’s need.
How did you learn this?
Do you have a link to some documentation?
After all, you don’t seem to be sure what it really does, so I’d suggest that with due diligence, this also would need some more grepping and code reading/checking before use, wouldn’t it?
I think the hoops we need to jump through are due in part to canalizing the file upload along a path where crackers can’t easily abuse a door too wide open for XSS and similar nefarious purposes.
That said, the file “Upload” dialog contains some almost-lies: files referenced by “Links” are NOT uploaded as one would expect, only the link itself. This could get a site or its admins into trouble if the referenced site disappears, and some other sites might even post a “image stolen from …” image to discourage deep linking and bandwidth hogs.
Also, it doesn’t say how files can be put into the “Library”.
This resembles the question of the OP, but he got it there by his own (thus trusted) path.
The REST API documentation has some info about file uploads:
https://frappeframework.com/docs/user/en/api/rest#file-uploads
But really, who will use curl for mass file uploads? You could, but who doesn’t like some python example?
Also it links to JS code useable in a JS client script. Why not.
But why not also link to the python implementation code in the handler?
And ideally supply a piece of python code to link to it?
Is the doc only meant for experienced devs and beginner users, but not for those in-between?
Is this policy, or more like a by-product of agile development of a team dedicated to unicorn-building-chasing?
But I’d suggest, once again, that mass adoption probably comes from including the many devs, not just the ahead of the curve-devs building MVPs – very polished ones, that is, indeed – and then catching up.
But the many also need to imply themselves documenting stuff. This forum could help
more with quality How-tos, as some forum members already build.
Which is why I write these longish and verbose explanations of finding your way around in The Thing.