Skip to content

Downloads demo

Native browser download capture — click a link and poll for the file bytes.


grab-image

Click a download link and capture the PNG bytes.

curl -s -X POST localhost:8765/tasks/downloads/grab-image -d '{}'
goto "https://example.com/page-with-download"
download-each files selector "a.download-link" timeout 30000

Concepts: download-each, native CDP download behavior (no WebDriver hacks).

sequenceDiagram
    participant S as webtasks
    participant C as Chrome
    participant FS as Download dir

    S->>C: Browser.setDownloadBehavior
    S->>C: click download link
    C->>FS: file bytes written
    S->>FS: poll until complete
    S-->>S: return base64 + metadata

Download strategies

webtasks supports two download paths:

Method When to use
download-each Normal <a download> or Content-Disposition links
Blob hook (js) Apps that decrypt client-side before download (see Concio)

The Concio bundle uses a URL.createObjectURL patch to capture encrypted blobs — see Concio → capture-files.


Configuration

Downloads land in WEBTASKS_DOWNLOADS_DIR (default: system temp). Each window gets an isolated subdirectory.


What's next?