pocketenv/copy

Transfer files between your local machine and a sandbox, or between two sandboxes.

Values

pub fn copy_to(
  sb: sandbox.ConnectedSandbox,
  dest_sandbox_id: String,
  src_path: String,
  dest_path: String,
) -> Result(Nil, pocketenv.PocketenvError)

Copies src_path from this sandbox into dest_path on dest_sandbox_id.

No local I/O is involved — the transfer goes directly through storage.

Example

let assert Ok(Nil) = sb |> copy.copy_to(other_id, "/app/data", "/app/data")
pub fn download(
  sb: sandbox.ConnectedSandbox,
  sandbox_path: String,
  local_path: String,
) -> Result(Nil, pocketenv.PocketenvError)

Downloads sandbox_path from the sandbox to the local local_path directory.

The sandbox compresses the source path, which is then downloaded and extracted locally.

Example

let assert Ok(Nil) = sb |> copy.download("/app/logs", "./logs")
pub fn upload(
  sb: sandbox.ConnectedSandbox,
  local_path: String,
  sandbox_path: String,
) -> Result(Nil, pocketenv.PocketenvError)

Uploads a local file or directory to sandbox_path inside the sandbox.

The local path is compressed into a tar.gz archive, uploaded to storage, and then extracted by the sandbox at the specified destination path.

Example

let assert Ok(Nil) = sb |> copy.upload("./dist", "/app/dist")
Search Document