How to share an iCal file?

I have a script where I want to load the content of a file from a shared url and then re-share the actual file to other apps.

let fileUrl = args.fileURLs[0];
let iCalContent = FileManager.local().readString(fileUrl);
console.log(iCalContent);
ShareSheet.present(iCalContent);

It’s loading and sharing the content OK but unfortunately it’s shared as text which defeats the purpose. Is there a way to tell the ShareSheet what the content type “really” is?

The reason for this is that I want to pick the iCal attachment from what Fantastical shares (which includes additional text) and pass it on in isolation as a file.

Thanks for any help.

If my understanding of what you wish to achieve is correct, there are two issues here. If you wish to share the iCal file, you should not read the contents of the file as a string. There’s really no reason to read the contents of the file at all since you’ve already got a URL to the file. So your script would look like this:

let fileUrl = args.fileURLs[0];
ShareSheet.present(fileUrl);

That would share a reference to the file. However, I just tried this and it turns out there’s a bug in Scriptable where the fileURL is shared as a string rather than a reference to the underlying file. I’ve fixed this issue and the fix will be included in the next build.

2 Likes

Ah, I see. Sharing the url was the first thing I tried and it just shared it as a string, as you said.

I’ll just wait for the bug fix :slight_smile:

Thanks