#Asset Protocol Configuration

20 messages · Page 1 of 1 (latest)

wooden sleet
#

So I am creating instances of HTMLAudioElement and giving them an src, which, (afaik), requires the files to be hosted on a webserver. NextJS does this automatically on localhost:3000, I just have to put the files in my working directory (I'm not sure if this approach would work in a non-dev environment)

However, I want to also read the metadata of these files through Rust, which requires a filepath to the files on disk.

Right now, I have basically each file stored twice, and I want to somehow reconcile that so every file is only stored once each, in a directory selectable by the user.

idle zodiac
wooden sleet
#

Thanks

wooden sleet
#

Alright I'm trying this now and I'm getting
"NotSupportedError: The operation is not supported."
I got a little confused reading the documentation. Inside tauri.conf.json I added:

  "tauri": {
      "protocol": {
        "asset": true,
        "assetScope": ["$APPDATA"]
      },
      "security": {
        "csp": "default-src 'self'; img-src 'self' asset: https://asset.localhost"
      }
  }```
I wasn't sure if `$APPDATA` lined up with
```ts
const { appDataDir } = await import("@tauri-apps/api/path");

That was a little confusing to me, so might be a point of mistake?

#

yeah I've seen the problem
asset protocol not configured to allow the path: /Users/eilidh/Library/Application Support/com.tauri.dev/Aurora - Cure For Me.mp3/Aurora - Cure For Me.mp3

#

oh i see the problem i think lol

#

well even though the end is duplicated i think theres still a problem with my asset protocol

#

ok I fixed the duplication and yeah same problem

#

asset protocol not configured to allow the path: /Users/eilidh/Library/Application Support/com.tauri.dev/Aurora - Cure For Me.mp3

#

Asset Protocol Configuration

#
      "protocol": {
        "asset": true,
        "assetScope": ["**"]
      }

this works ig lol

idle zodiac
# wooden sleet `asset protocol not configured to allow the path: /Users/eilidh/Library/Applicat...

https://tauri.app/v1/api/config/#fsallowlistscope
The path specified doesn't by default apply recursively, it whitelists specific files, not entire directories. $APPDATA gets you to the /Users/eilidh/Library/Application Support/com.tauri.dev folder, but you need more to make it include the file. You can use $APPDATA/* to allow files in that directory. That however still won't be applied recursively. For that you need $APPDATA/**, which is the glob pattern for any depth

wooden sleet
#

ah ok thanks

#

that makes more sense

#

now just to work out why half my program broke

#

for some reason it seems to be struggling to get the reference to the audio player or something

#

its funny i can adjust the volume but not scrub through

#

id expect things to break when i did this but everything, not some things

idle zodiac
#

Huh that's weird >.<

wooden sleet
#

i worked it out, byproduct of doing this is that the initialisation code is now asynchronous. The audio player wasn't created until the path for the first file had been generated. This meant that some code was running before this was finished, and getting a null reference. To fix it, I just immediately created the audio player, and populated the source once its generated