INNER CODE UNIT · Rust

upload

keon/browser-control · src/actions.rs:203

pub async fn upload(c: &mut Cdp, selector: &str, paths: &[String]) -> Result<()> {
    let doc = c.call("DOM.getDocument", json!({}), true).await?["root"]["nodeId"]
        .as_i64()
        .context("nodeId")?;
    let node = c
        .call(
            "DOM.querySelector",
            json!({"nodeId":doc,"selector":selector}),
            true,
        )
        .await?["nodeId"]
        .as_i64()
        .context("file input not found")?;
    let files = paths
        .iter()
        .map(|p| Ok(fs::canonicalize(p)?.to_string_lossy().into_owned()))
        .collect::<Result<Vec<_>>>()?;
    c.call(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…