plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

Android forbidden path with @tauri-apps/plugin-fs create()

Open lindongchen opened this issue 1 year ago • 2 comments

[@tauri-apps/plugin-fs create()] Error: Uncaught (in promise) forbidden path: /storage/emulated/0/Android/data/com.flomesh.ztm/files/Documents/Readme.txt "/storage/emulated/0/Android/data/com.flomesh.ztm/" is my app private directory.

And the relevant read and write permissions have been applied for

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
         android:required="false"/>

And I set up capabilities:

  "permissions": [
...
{
	"identifier": "fs:scope",
	"allow": [
		{ "path": "$APPDATA" }, 
		{ "path": "$APPDATA/**" },
		{ "path": "$HOME" },
		{ "path": "$HOME/**" }
	]
},
"fs:allow-create",
"fs:allow-home-write", 
...
]

Also no permission under Android, but iOS / macOS can work normally. So I think it might be a bug

tauri-plugin-fs = "=2.0.1"

lindongchen avatar Oct 10 '24 12:10 lindongchen

Can you try this capability?

"fs:allow-app-write",

Grandkahuna43325 avatar Jan 22 '25 19:01 Grandkahuna43325

Ok, so I'm also trying to do something with fs plugin and this solution didn't error for me:

    {
      "identifier": "fs:scope",
      "allow": [
        {
          "path": "$DOWNLOAD"
        }
      ]
    },
    {
      "identifier": "fs:allow-write",
      "allow": [
        {
          "path": "$DOWNLOAD"
        }
      ]
    },

now keep in mind that didn't error doesn't mean it worked, I see no error but I also don't see no file. It may be issue with fs not being implemented for android, I'll try to get a hold of amrbashir, he helped me last time with similar error.

Grandkahuna43325 avatar Mar 13 '25 18:03 Grandkahuna43325