Getting file contents?

Hey so I’m looking to get the contents of a file (it’s a .md file), and display it on a widget.
I was told to use the wg function, so I put the path into that, used raw, and it’s not returning anything.

Am I doing this correctly, or should I be doing this another way?
Thanks!

Here’s what I’m using rn:
$wg(“/Internal storage/Obsidian Vault/Lists/Tasks/General TODO.md”, raw)$

First, I suggest moving the file inside the Kustom folder to avoid any access issues. After doing that, use the format from the sample below.

$wg(“file:///Kustom/testfile.txt”,raw)$

1 Like

Hmm ok, so from what I’m understanding is it can only be a .txt file to get the raw data, or can I get a .md file as well?
(It’s not encrypted or anything, just markdown format)

Also I cannot move the file outside the current location since it’s synced in a specific place from a 3rd party app.
Can I use an absolute location?

Thanks!

If this is a markdown file, it should be compatible. As for the location, there’s no guarantee it’ll work outside the Kustom folder. This is due to Google’s change in storage access policy.

Hi there,

In addition to Ace’s reply…

You can use $wg("file:///…", raw)$ to retrieve the file as it is or $wg("file:///…", txt)$ to retrieve the file as plain text.

I hope this would help.
:smiling_face::+1:

2 Likes

This is also not working even kwgt has access to this folder. I am facing error java.io.ioexception: unable to read the file. I put simple .txt file there. Even copy pasting the exact address won’t work.

Please help me on the error I mentioned in reply to the @Ace

Hi there,

Have you tried this?

$wg("/kustom/…", raw)$

I hope this would help.
:smiling_face::+1:

1 Like

Thanks. It still not working. Here is the file path /storage/emulated/0/KWGT/Kustom/test.txt
Same issue is with json file which i also have copied to this folder.

It might work if you shorten the file path to only include from KWGT onwards - $wg("file://KWGT/Test/TestFile.md", raw)$ worked for me for a filepath of /storage/emulated/0/KWGT/Test/TestFile.md (it also works with 3 /s after file:; I don’t think it makes much of a difference but I could be wrong on that)