Drafts Reference

FileManager

FileManager objects can be used to read from or write to files in either the local Drafts app Documents directory (as visible in the Files.app), or iCloud Drive (inside the “Drafts5” folder).

Properties

Instance Functions

Class Functions

Examples

// create a local file in App documents
let fmLocal = FileManager.createLocal(); // Local file in app container
let success = fmLocal.writeString("/ScriptedFile.txt", "This is the file content");

// read from file in iCloud
let fmCloud = FileManager.createCloud(); // iCloud
let content = fmCloud.readString("/Test Folder/Test.txt")

// create a directory, and move a file to it
fmCloud.createDirectory("My Folder", "/");
fmCloud.moveItem("/TestFile.txt", "/My Folder/TestFile.txt", false);