Read File
Reads a file an earlier step produced into one value, its text, its JSON or its bytes as Base64, so what the file says can be used by later steps like any other value. The file itself stays in storage; only the one reading this step makes travels through the run.
You don't need this step to pass a file along or link to it. A file is already a value in the run: its Public URL, Content Type and name are in the variable picker wherever the file is, so an image uploaded to a trigger can go straight into a Slack message or an HTTP upload. Read File is for getting at what a text file says.
Read File reads text files: plain text, JSON, CSV, XML and the like. No step extracts the text of a PDF, Word document or image. A file like that can still be passed along by its Public URL, attached to an email or uploaded by an HTTP Request, or read as Base64 for an API that takes files inline.
A file reaches a run in two ways: a trigger whose payload has a file field, such as an On Demand trigger whose payload is a content type with a file, or an HTTP Request whose response was saved to storage and appears as Body (File). Either shows in the variable picker as a file, with its name and content type.
Fields
| Field | Description |
|---|---|
| File | The file to read. Bind a file from an earlier step; the picker offers only the files earlier steps produce. |
| Read As | What to read the file into. Text decodes a text file. JSON parses a JSON file, failing the step if it doesn't parse. Base64 outputs any file's bytes as Base64, for an API that takes a file inline. Text when unset. One reading per step, since each is the whole file in another form. |
| Max Size and its Unit | Under Advanced. A file larger than this fails the step rather than being read into memory. 1 MB when blank. |
What later steps see
| Output | Description |
|---|---|
| Text, JSON or Base64 | The one reading Read As chose. Text is decoded with the charset the content type names, or UTF-8 when it names none. |
| Content Type | The file's content type. |
| Size (bytes) | How many bytes were read. Absent when the file was described rather than read. |
| File Name | The name the file was uploaded under when that was recorded, else the last part of its path. |
Behaviour
Text and JSON read a file whose type is text-like (text/*, or an application/* type naming JSON, XML, JavaScript, YAML, CSV or form data) or unknown, as a file added by URL usually is. A file whose type says it is something else, such as an image or a PDF, is described rather than decoded: the step completes with Content Type and File Name, no reading, and a line in its log saying so. Base64 takes any file within Max Size.
The size cap is enforced while reading, so a large file bound by mistake stops at the cap and fails the step naming the limit, rather than being read into memory first.