Is it possible to create a file inside .obsidian folder?

I’m developing a plugin for personal use and I need to store information on a json file, I don’t want a random note flying around on my vault nor wanna create a folder just for it.

I tried so hard to create it inside the .obsidian folder but it just keeps giving me “Uncaught (in promise) Error: Folder already exists.” for it, the algorithm works perfectly otherwise.

Is it even possible to create anything inside of any folder start starts with a “.” like “.folder” or “.myPlugin” (besides the normal plugin configuration with the API commands)? If so, is there any examples of it? I didn’t find anything in the documentation.

It’s certainly possible.
What’s your current code?

1 Like

app.vault.adapter.write, .read, .writeBinary, and .readBinary all let you read and write files anywhere you like.

Here’s a full typescript example from one of my plugins:

export async function save (this: HistoryDb) {
  const data = this.db.export().buffer
  await this.app.vault.adapter.writeBinary(this.pluginFile('history.db'), data)
}

export function pluginFile (this: HistoryDb, filename: string) {
  const path = [
    this.app.vault.configDir,
    'plugins',
    thisPluginId,
    filename
  ]
  return path.join('/')
}
2 Likes

Sorry it took so long for me to reply. This is what I wanted. Thank you so much.