diff --git a/packages/capacitor-plugin/src/web.ts b/packages/capacitor-plugin/src/web.ts index 1962d2f..fdc3ea6 100644 --- a/packages/capacitor-plugin/src/web.ts +++ b/packages/capacitor-plugin/src/web.ts @@ -12,6 +12,7 @@ import type { // Type definitions for the Capacitor Filesystem API interface FilesystemPlugin { readFile(options: { path: string }): Promise<{ data: string }>; + stat(options: { path: string }): Promise<{ data: string }>; writeFile(options: { path: string; data: string; @@ -469,9 +470,11 @@ export class FileTransferWeb extends WebPlugin implements FileTransferPlugin { const pathParts = path.split("/"); if (pathParts.length > 1) { const directory = pathParts.slice(0, -1).join("/"); - await filesystem.mkdir({ - path: directory, - recursive: true, + await filesystem.stat({path: directory}).catch(async ()=>{ + await filesystem.mkdir({ + path: directory, + recursive: true, + }); }); }