Download and upload image from URL
card_builder_upload_image_from_urlDownload an image from an http(s) URL and upload it to the Card Builder media library, sanitizing SVG files and blocking reserved or loopback addresses.
Instructions
Download an image from an http(s) URL and upload it to the Card Builder media library.
Only http/https schemes are accepted. The response must declare an
image/* Content-Type (covers image/svg+xml) and stay within
_MAX_URL_IMAGE_BYTES, else nothing is uploaded. image/svg+xml is
sanitized (see sanitize_svg) regardless of filename, since the
remote server controls the bytes. The file becomes public under
/local/ with no authentication, and an existing path/
filename is silently overwritten.
The URL and every redirect hop are resolved and rejected on a
loopback, link-local, unspecified, multicast or other reserved
address (incl. ::ffff:127.0.0.1) — host_network: true means
127.0.0.1/localhost here can reach host services that trust it as
a local peer. Private LAN ranges stay allowed (e.g. a camera snapshot
on your own network).
Use when: mirroring a remote image into the media library.
Not for: bytes already in memory — use card_builder_upload_media; a
file on disk — use card_builder_upload_media_from_path.
Returns: {reference, path, url}.
Errors: {"error": "scheme_not_allowed" | "target_not_allowed" | "dns_resolution_failed" | "too_many_redirects" | "content_type_not_allowed" | "file_too_large" | "download_failed" | "invalid_svg" | ...}.
Limits: 30-second timeout, _MAX_URL_IMAGE_BYTES (15 MiB) cap, up to
_MAX_URL_REDIRECTS (5) redirects, each re-validated.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | http(s) URL of the image to download, e.g. 'https://example.com/bg.png'. | |
| path | No | Sub-folder under www/card_builder/ to upload into. Empty string uploads to the root. | |
| filename | No | Target filename to store as. Omit to derive one from the URL's last path segment. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||