Upload data file
upload_data_fileStore a JSON or CSV data file for the site and get a public URL that an embed's script can fetch() — for a browser-side widget that needs a dataset (a product finder, a price table, a store locator). Never paste the data into the embed itself, and never hide it in an image. Sources, exactly one: url (a public link — published Google Sheet, Drive/Dropbox share link, any direct file), content (inline text up to 100,000 characters), or mode:"link" (the owner uploads the file in their browser). Up to 2MB stored. Same name replaces the file at the same URL. A CSV is stored as an array of row objects (as:"csv" keeps it as given). Returns the url, row count, the data's shape and a ready fetch line.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as | No | What a CSV is stored as. "json" (default): an array of row objects (header row = keys; plain numbers become numbers, leading-zero values like zip codes stay strings), so the widget reads it with fetch(url).then(r => r.json()) and never parses CSV. "csv": the file as given. JSON input is stored as JSON either way. | |
| url | No | A public link to a JSON or CSV file, fetched by Sitelas. Works with a Google Sheet published to the web as CSV, a Google Drive or Dropbox share link set to 'anyone with the link' (rewritten to its direct download), or any direct file URL. Use this for anything big. Give exactly one of url, content or mode. | |
| mode | No | "link": the file is on the owner's computer. Returns a one-time upload page (link_url) to give the owner; the file lands at the returned url once they upload. Give exactly one of url, content or mode. | |
| name | Yes | File name: lowercase letters, digits and hyphens, 1–64 characters, no extension (e.g. 'car-models'). Uploading again under the same name REPLACES the file, and its URL stays the same — so a widget keeps working when the data is updated. | |
| content | No | The file's text, JSON or CSV, written inline — up to 100,000 characters. Bigger data must come through url, or mode:"link" for a file only the owner has. Give exactly one of url, content or mode. | |
| site_id | Yes | The site the data file belongs to. |