I have a feeling I’m missing something obvious, but is there a way to save a draft as a file in iCloud Drive but outside the Drafts folder?
Only using an Export action step and manually selecting the destination. Sandbox limitation, apps can’t write programmatically outside their own container.
I feared as much. Was hoping there was a clever way to encode the full path in the title line instead of having to use the GUI.
How does an app like Textor automatically know where to save as you update the file? I don’t expect, or want, Drafts to be file-based, but it would be nice if I could choose a target once and then export to that same spot each time I update.
If an app supports editing documents in place and opens a document via the file browser, it is given a URL and iOS punches a hole in the Sandbox for that specific file - allow it to write back changes to the file.
The problem for doing something clever with that in Drafts, is that if I declare support for editing in place, it changes a bunch of other behaviors that are not necessarily supported or compatible…so I can’t just enable it to allow for tricky actions that target those files.
On a similar theme, forgive me as I haven’t set up an action to test as yet, but can Drafts write a text file to the new ~Templates folder within the Drafts iCloud folder?
Apologies - Have just had a minute to try this and can indeed write to Library>Templates.
Thanks, Greg. A clear explanation of what you’re up against. I’m probably trying to stretch Drafts beyond its limits.
Back with Drafts 4, I had a system that would save everything to a Drafts folder in Dropbox with a
--folder appended to the filename. I set up Hazel to read the
--folder, sort into the appropriate directory, and remove the filename extension. It’s a kludge but it worked well once it was all set up.
Well, that’s a thought. I could set up a Dropbox folder as a sort of way-station, saving to there from Drafts (which is easy to automate) and then using Hazel to keep that folder in sync with places in iCloud Drive. Thanks!
I recognize that I’m over a year late to this thread, but I was looking for similar solution this morning, and decided to go the Hazel route. I’m keeping the action name as ‘Save to iCloud’ and using Hazel to monitor the Drafts Library folder and moving the file into iCloud, which seems to be working well for me.
Seeing your reply made me realize there’s a way around this now. Scriptable has a way to “bookmark” folders anywhere in iCloud Drive, and any folder (or subfolder) that’s bookmarked can have files written to it from within Scriptable. So you can write a Drafts action that runs a Shortcut that calls Scriptable (inline) to write the contents of a draft wherever you like. It’s all done on your iDevice with no need for a Mac/Hazel intervention.
This morning I worked up an action and shortcut to do this. It’s too complicated to put here, but I’ll write a post about it in the next day or two.
Also, Toolbox Pro is testing a similar bookmarking feature, which might make this a bit easier. And if Scriptable and Toolbox Pro can do it, maybe we can prevail upon Greg to add that feature to Drafts. Then iCloud Drive would be on nearly the same footing within Drafts as Dropbox, Box, Google Drive, etc.
The “bookmarking” feature you refer to is something I’ve looked at. I don’t love it because it’s a bit fragile and a “bookmark” can’t be synced across devices/platforms. I’ve got it on the list to think about a reasonable implementation in actions that makes sense for Drafts.
After reading your reply, I started testing on another device and found some of that fragility. No data loss, but after my iPad saved a draft to a file named “proposal.tex,” my iPhone refused to write to that same file. Insisted on creating a new file, “proposal 2.tex.”
For those interested, links to an action and shortcut, along with an explanation of how they work, are here: https://leancrew.com/all-this/2020/05/drafts-and-icloud-drive/
On the bookmarks on multiple devices, check out Simon’s (Scriptable’s developer) comments on this thread on the Automators forum. It make give you a way forward on the duplication you wrote about.
For interest, the next release of Toolbox Pro should bring bookmarks (it is in the current beta).
Well, I am using the same name for the bookmark on every device. It’s possible that using bookmarks to files doesn’t have the issue I’ve run into, but I need to use a bookmark to a folder for my system to be worthwhile. I’ll send off a support email to see if I can learn more.
And I am looking forward to trying out bookmarks in Toolbox Pro. I saw mention of it in the Automators (I think?) forum last week.
I’ve just run some multi-device overwrite tests on the Toolbox Pro beta, and while I can overwrite a file to a bookmarked folder from the device on which the file is first created, any attempts to overwrite using an identically configured bookmark on a second device results in a duplicate file.
I’ll drop Alex, the developer, a note to check it is something he’s also aware of.
I get a feeling that this may be an Apple-level issue.
I’ve just force closed a few apps (Files, Shortcuts Toolbox Pro(Beta)), retried the tests, and the result is that I not only have both an iPhone and an iPad updating the same file in a non-Shortcuts folder, but also seeing this update a few moments later in iCloud on my Mac.
It looks like it would work; though maybe the issue I came across earlier will resurface in more persistent use. But the potential is certainly there.
I hate stochastic behavior in my apps.
I agree, and I’m really hoping the next OS releases bring more stability and reliance around Shortcuts. I’ve been bumping into odd behaviours in foundation level stuff all year, and while things are certainly better and generally improving, I wouldn’t describe them as good yet.