Upload local file to Card Builder media
card_builder_upload_media_from_pathUpload a local file from Home Assistant's config www or media folder into the Card Builder media library by providing its path.
Instructions
Read a local file under the HA config directory and upload it as Card Builder media.
local_path must resolve (after following symlinks) under <config>/www
or <config>/media, and have an image/SVG extension — see
_ALLOWED_MEDIA_EXTENSIONS. Anything else (e.g. secrets.yaml,
/data/options.json, a sibling directory) is refused before the file is
read. .svg files are sanitized (script/event-handler/unsafe-URL
stripping) before upload — see sanitize_svg. The uploaded file
becomes public under Home Assistant's /local/ path with no
authentication. Upstream's _write_media_file writes with no
existence check, so uploading onto a path/filename that already
holds a file silently overwrites it, with no backup.
Use when: re-publishing a file that already exists on the config
filesystem (e.g. under www/) into the Card Builder media library.
Not for: bytes already in memory — use card_builder_upload_media; a
remote URL — use card_builder_upload_image_from_url.
Returns: {reference, path, url} on success, same shape as
card_builder_upload_media.
Errors: {"error": "invalid_path" | "path_not_allowed" | "extension_not_allowed" | "file_not_found" | "invalid_svg" | ...}
(plus the sanitize_svg errors) when the source path is outside the
allowed roots, has a disallowed extension, doesn't exist, or fails
sanitization.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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 reuse local_path's own filename. | |
| local_path | Yes | Absolute or relative path to the source file; must resolve under <config>/www or <config>/media. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||