DataAdapter

DataAdapter interface

Work directly with files and folders inside a vault. If possible prefer using the Vault API over this.

Signature:

export interface DataAdapter 

Methods

MethodDescription
append(normalizedPath, data, options)Add text to the end of a plaintext file.
copy(normalizedPath, normalizedNewPath)Create a copy of a file. This will fail if there is already a file at normalizedNewPath.
exists(normalizedPath, sensitive)Check if something exists at the given path. For a faster way to synchronously check if a note or attachment is in the vault, use Vault.getAbstractFileByPath().
getName()
getResourcePath(normalizedPath)Returns an URI for the browser engine to use, for example to embed an image.
list(normalizedPath)Retrieve a list of all files and folders inside the given folder, non-recursive.
mkdir(normalizedPath)Create a directory.
process(normalizedPath, fn, options)Atomically read, modify, and save the contents of a plaintext file.
read(normalizedPath)
readBinary(normalizedPath)
remove(normalizedPath)Delete a file.
rename(normalizedPath, normalizedNewPath)Rename a file or folder.
rmdir(normalizedPath, recursive)Remove a directory.
stat(normalizedPath)Retrieve metadata about the given file/folder.
trashLocal(normalizedPath)Move to local trash. Files will be moved into the .trash folder at the root of the vault.
trashSystem(normalizedPath)Try moving to system trash.
write(normalizedPath, data, options)Write to a plaintext file. If the file exists its content will be overwritten, otherwise the file will be created.
writeBinary(normalizedPath, data, options)Write to a binary file. If the file exists its content will be overwritten, otherwise the file will be created.