Pass Shortcut Input file to Scriptable

Hi there

I have searched the forum for similar issues, but can’t find a solution to a problem that I’ve been working on… hopefully someone here can point me in the right direction.

I have a Shortcut that is launched from a share sheet and accepts a PDF file as input.

I’d like to access the PDF file in a Scriptable script in order to POST it to an HTTP API. I need to use Scriptable to do the POST because the body needs to be multipart and I need to add the file in one part and the file data in another.

I’ve tried passing “Shortcut Input” as the parameter for the script, which allows me to execute QuickLook.present, in the script, but it doesn’t allow me to access the file.

Then I tried adding a Shortcut step to create a named bookmark for the Shortcut Input file, which I then read in the script, but I get an error unable to read the file.

Can anyone advise the best way to pass the shortcut input file to the scriptable script?

Any help would be appreciated.

Hi!
In the docs is written that args.shortcutParameter contains the path to the file if it can’t be read as JSON or plain text.

I’ve now tried some things with it and it seems that this is true, but it is not a javascript string. To convert it to one, just write file = "" + args.shortcutParameter. To then read the file, use Data.fromFile(path) and append that to the multipart request.