Files in a running sandbox.
Every call goes through the guest's exec agent, so the sandbox has to be running — there is no offline write. Each function takes the machine id, in keeping with the rest of the SDK.
(require '[bsdkrun.filesystem :as fs])
(fs/write-file "web" "/app/main.py" "print('hi')")
(fs/read-text "web" "/app/out.json")
(fs/upload "web" "./src" "/app/src")
(fs/download "web" "/app/dist" "./dist" {:recursive true})
Files in a running sandbox.
Every call goes through the guest's exec agent, so the sandbox has to be
running — there is no offline write. Each function takes the machine id, in
keeping with the rest of the SDK.
(require '[bsdkrun.filesystem :as fs])
(fs/write-file "web" "/app/main.py" "print('hi')")
(fs/read-text "web" "/app/out.json")
(fs/upload "web" "./src" "/app/src")
(fs/download "web" "/app/dist" "./dist" {:recursive true})(download id remote-path local-path)(download id remote-path local-path {:keys [recursive]})Copy a file or directory out of the guest onto the host.
Pass {:recursive true} for a directory; unlike upload it cannot be
detected here, because the path lives in the guest and answering would cost
an extra round trip on every call. Returns nil.
Copy a file or directory out of the guest onto the host.
Pass `{:recursive true}` for a directory; unlike [[upload]] it cannot be
detected here, because the path lives in the guest and answering would cost
an extra round trip on every call. Returns nil.(read-file id path)Read path from the guest as a byte array.
Read `path` from the guest as a byte array.
(read-text id path)(read-text id path encoding)Read path from the guest and decode it (UTF-8 by default).
Read `path` from the guest and decode it (UTF-8 by default).
(upload id local-path remote-path)Copy a host file or directory into the guest.
A directory's contents land in remote-path, so
(upload id "./src" "/app/src") leaves the guest's /app/src holding
what ./src holds. Whether it recurses is decided by looking at the local
path, so callers do not have to say which kind of thing it is. Returns nil.
Copy a host file or directory into the guest. A directory's *contents* land in `remote-path`, so `(upload id "./src" "/app/src")` leaves the guest's `/app/src` holding what `./src` holds. Whether it recurses is decided by looking at the local path, so callers do not have to say which kind of thing it is. Returns nil.
(write-file id path data)Write data (a string or byte array) to path in the guest, creating
parent directories. Returns nil.
Write `data` (a string or byte array) to `path` in the guest, creating parent directories. Returns nil.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |