Course lesson 31 · Building AI Workflows
Saving Web Page Data in R2
The workflow backs up rendered page evidence to R2 and links it to the evaluation saved in D1. The lesson explains why relational records belong in a database while larger documents and images fit object storage, then uses a shared evaluation ID to connect those two kinds of data. Inspecting the stored AliExpress text confirms that the renderer did not collect the expected product information, giving a concrete reason to improve observability.
Primary source: course video 31 · Supplied English subtitles · 00:15:36.
Understand the idea
- D1 stores queryable application records; R2 holds large evidence objects addressed by keys.
- A database record can act as an index into object storage by retaining an identifier used in object keys.
- The course organises evaluation evidence by account, evaluation identity, and content kind.
- Object-storage access centres on known keys and prefixes rather than relational joins.
- An R2 binding exposes storage operations directly inside the Worker environment.
What the course does
- Enable R2 in the course account and create a staging evaluation bucket with standard storage.
- Add its binding and bucket name to Wrangler, then regenerate environment types.
- Use the evaluation ID returned by the preceding database-save step to build the evidence paths.
- Write the rendered HTML and extracted body text to separate R2 objects.
- Deploy and trigger a workflow; check both the new D1 record and the corresponding R2 objects.
- Download the text and HTML to investigate why the model returned unknown for the AliExpress page.
Watch for
- This initial ordering is superseded by lesson 34: evidence storage moves into the first step, and the evaluation ID is created earlier.
- Recorded pricing, free allowances, storage-class beta status, and jurisdiction commentary should not be treated as current operational or legal guidance.
- The instructor suspects bot detection, but the observed fact here is missing expected content; the cause is not proved in this lesson.
Follow the final workflow correction in lesson 34 when combining these steps.
Recall before revealing
How can a database query lead to the exact evidence objects for an evaluation?
Reveal the explanation
The evaluation’s ID and account identify the object-key pattern, so query results provide the information needed to retrieve those objects.
Try it
Design key names for one evaluation’s HTML, text, and screenshot, then write the minimum database fields needed to locate them.
Check your result
All three objects are unambiguously associated with the same evaluation and can be located without scanning their contents.
Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.
Rewatch only what you need
Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.
- 00:00:33 — Database records versus large objects
- 00:05:15 — Creating the staging R2 bucket
- 00:08:12 — Backup step and account-based paths
- 00:09:25 — Connecting D1 and R2 with an evaluation ID
- 00:12:24 — Inspecting stored text to debug missing content
Companion primary documentation: Workflows Workers API. For recorded API names, commands, limits, and prices, check the version you use.