API access to settings "files and Links" > "Default localtion for Attachments"

Use case or problem

Obsidian has an option Under “files and Links” > “Default location for Attachments” for where to store attached files. I would like API access to this in order to make this a default “inherited” option for me to store the TeX images in my Plugin ?

Proposed solution

An Obsidian API settings call to get all the Obsidian settings including “files and Links” > “Default localtion for Attachments”

Current workaround (optional)

Not sure if there is one.

Related feature requests (optional)

none

Use: getAvailablePathForAttachment - Developer Documentation

Yes I saw this function but it does not seem to do what I require.

getAvailablePathForAttachment(filename: string, sourcePath?: string): Promise;

I literally need to access the “Default location for new attachments” field value setting and if it needs the “Attachment folder path” that value too !

Accessing the raw settings value can be confusing, there are a bunch of edge cases that you would need to handle.
The function takes care of that and will give you the path the attachment should be saved at according to user preferences.

@joethei Can you give me code snippet(s) please.

 const filename = "example.xyz";
const path = await this.app.fileManager.getAvailablePathForAttachment(filename, this.app.workspace.getActiveFile().path);
await this.app.vault.createBinary(path, content);