Unix path to file in panel hook?

I’ve had a panel hook in place for awhile that renames my uploaded files based on date and page slug. I’ve then manually fed them to a script that uploads them to an object storage service, and then deleted them from the folder.

Now I’m trying to implement the uploading to object storage as part of the hook, and I haven’t figured out how to get my script working in PHP. This isn’t a big deal, as I have it working as a shell script. The problem is, I need to pass the complete unix file path to the shell script, and I can’t figure out how to get that from the $file object in my Kirby panel hook.

This has to be easier than I’m making it, right? Can anybody point me to how to get that path?

$file->root() should do the job.

That does the trick, thanks. And I verified that it’s outputting the correct path. Now if only I could figure out why it’s not running the shell script. :-/

How do you call the shell script?
Do you get any error messages?
Might be a permission problem?

Tried calling with exec and shell_exec. Shouldn’t be permissions issues because locally for testing it’s running as my user. I can manually run the script exactly as PHP outputs it. Maybe some sort of environment issue, but I am using full paths for everything as near as I can tell.

Could be an issue getting the SSH key it needs to run the stuff that’s in the shell script, but since it’s running as my user, I don’t see how that would be an issue, but maybe it is.

If I set the shell_exec as being assigned to an $output variable, and then dump that to a text file, there’s nothing there. No errors, no output as it would normally have if it’s successful. The process does take longer when uploading the file in the panel, though, so it’s trying to do something.

Really, I should probably figure out how to get this working with a Kirby hook. I’ve tried before, very unsuccessfully.

Well, I just realized that since the primary reason I’m setting this up is to have an iOS-based workflow option, and since I don’t believe I can upload mp3 files from iOS Safari, I’m better off having a script that triggers based on changes to the unix file system instead of based on panel uploads.

So I think I’ll try to figure out how to use fswatch to do what I need to do.

Thanks for your help.