Skip to content

TExternalFile

Official

Represents a file that is outside the Vault. Can be used with the vault API just like any other file. Do not create these manually.

Import:

import { TExternalFile } from 'obsidian';

Signature:

export class TExternalFile extends TFile

Extends: TFile

Constructor

new TExternalFile(vault: Vault, path: string)

Constructor.

To get the constructor instance, use getTFileConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
basenamestringThe basename of the file (name without extension).
(Inherited from TFile)
extensionstringThe extension of the file.
(Inherited from TFile)
metadataCachedMetadata | nullCached metadata, cleared when the file changes or loses its last user.
monitorExternalFileMonitorMonitor watching this file for external changes.
namestringThe name of the file (with extension).
(Inherited from TFile)
savingbooleanWhether the file is being saved.
(Inherited from TFile)
statFileStatsThe stats of the file.
(Inherited from TFile)
usersSet<unknown>Identities retaining the file for external change monitoring.

Methods

MethodReturnsDescription
addUser(user)voidRetains a user and starts external change monitoring if necessary.
cache(content)voidCaches file's content, that can be retrieved via await app.vault.cachedRead(file).
(Inherited from TFile)
getRealPath()stringReturns the physical path in the filesystem.
getShortName()stringGets the short name of the file.

For a/b/c.md, it returns c.

For a/b/c.any-other-extension it returns c.any-other-extension.
(Inherited from TFile)
hasUsers()booleanChecks whether any users retain this file.
removeUser(user)voidReleases a user; the last release stops monitoring and clears cached data and metadata.
updateCacheLimit()unknownRemoves the file from the cache if its content length greater than app.vault.cacheLimit.
(Inherited from TFile)

Links to this page: