On Thu, 10 Aug 2023 at 14:27, BD dzidek23@gmail.com wrote:
This is a question and a half as not many people would do it from a command line.
Not many people use the command line in the first place, but it's surely not an odd idea for those who do. And commandline -> script -> GUI accessible anyway (eg if I wanted to right-click a file in my favourite GUI, select "share via my cloud", and have the result be a read-only share link copied to my clipboard, then that would likely have the same solution).
Not sure if this would be of any help but I'm almost sure you can't produce shares from the occ command so API is the only way:
ChatGPT gave me something like "$NEXTCLOUD_URL/ocs/v2.php/apps/files_sharing/api/v1/shares" as a way to share, Bard thought "$nextcloud_url/index.php/apps/files/ajax/share?fileid=XXX" was the way to go. It's quite possible both were hallucinating though - I couldn't get either script to work and they were failing at the "get file ID" stage so I never got as far as testing the "get share link from this file id" bit.
I spent some time looking at the API docs before posting her but they're not really written from the perspective of throwing together a quick script.
Wouldn't it be easier to just share the file manually from either the website or NC client :) ?
Define easier! I've been using a script to do the upload (via DAV) for years because I found it more convenient than logging in and dragging and dropping a file. But increasingly I'm finding that the reason I'm uploading is because I need to share by email a file that isn't suited to email, so I'm using my script to upload then having to log in to get the share link. I guess if you're working at a command line then that's where the file you want to upload is going to be so a scripted upload is going to be more convenient than opening a file browser and a web browser to do it.