websave — Download URL content into a file.
websave downloads an HTTP or HTTPS response to a file and returns the saved filename.
Syntax
filename = websave(filename, url)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
input1 | Any | Yes | — | First input argument. |
input2 | Any | Yes | — | Second input argument. |
Returns
| Name | Type | Description |
|---|---|---|
value | Any | Result value. |
How websave works
- Downloads HTTP or HTTPS URL content through the shared RunMat HTTP transport and writes it through the active filesystem provider.
- The filename and URL are host text values. Native integer and resident numeric values are rejected for these roles.
- Query names are text. Query values may be text, numeric, or logical scalars or vectors; native integers are formatted exactly and vectors use comma-separated formatting.
- A final options structure can supply
Timeout,UserAgent, andHeaderFields. The default timeout is 5 seconds, and an integer timeout is read exactly. - RunMat also recognizes direct
TimeoutandUserAgentname-value pairs as request options. - Rejects unpaired or unsupported option shapes instead of silently ignoring them.
Does RunMat run websave on the GPU?
The request path gathers automatically resident query values through their owning provider. Explicit gpuArray input crosses the websave-explicit-gpu-input extension gate before any gather.
GPU memory and residency
The network request and saved result are host-side. Automatically resident values can gather transparently; explicit gpuArray input requires RunMat mode.
Example
Download a file with a query value
saved = websave("report.json", "https://api.example.com/report", "id", uint64(42))Using websave with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how websave changes the result.
Run a small websave example, explain the result, then change one input and compare the output.
FAQ
Does websave require a manual gather?⌄
No manual gather is needed for automatically resident query values. Explicit gpuArray input is a named RunMat extension and is rejected before provider access in MATLAB-compatible mode.
Related Io functions
Repl Fs
addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite
Tabular
arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines
Import
Json
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.