You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sites/cheerpj/src/content/docs/11-guides/filesystem.mdx
+54-52Lines changed: 54 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ description: Interacting with the virtual filesystem in CheerpJ
6
6
CheerpJ provides a **virtual filesystem** that lets your Java application read and write files inside a secure, browser-sandboxed environment. For browser security reasons, it cannot access the user’s actual local disk. All file operations happen within this virtual space.
7
7
8
8
> [!info] Mounting points overview
9
+
>
9
10
> -**`/app/`** — HTTP-based filesystem for loading files from your web server; **Write**: No, **Read**: Yes.
console.log(`File "${fileName}" added to /str/.`);
37
+
} catch (e) {
38
+
console.error("Error writing file to /str/:", e);
39
39
}
40
+
}
40
41
```
41
42
42
43
### Method 2: Using library mode
@@ -68,6 +69,7 @@ async function copyFileToFilesMountPoint() {
68
69
When Java runs under CheerpJ, files are saved in the virtual filesystem (typically under **`/files/`**), not directly to the user’s disk. To make a file available to the page (for download, upload, or preview), expose it via a **Java native method** implemented in JavaScript. The JavaScript side reads the bytes from the VFS and then uses standard browser APIs (e.g., create a `Blob`, trigger a download, or upload it).
69
70
70
71
**Example flow**
72
+
71
73
1. Java writes/generates the file (e.g., under **`/files/`**).
72
74
2. Java invokes a JavaScript **native method**.
73
75
3. JavaScript reads the file from the VFS and processes it (e.g., create a `Blob` and trigger a download).
@@ -105,33 +107,33 @@ Now we’ll implement the JavaScript for `downloadFileFromCheerpJ`. The function
0 commit comments