Skip to content

Save scratch assets to bucket#827

Draft
zetter-rpf wants to merge 4 commits into
mainfrom
save-scratch-assets-to-bucket
Draft

Save scratch assets to bucket#827
zetter-rpf wants to merge 4 commits into
mainfrom
save-scratch-assets-to-bucket

Conversation

@zetter-rpf
Copy link
Copy Markdown
Contributor

@zetter-rpf zetter-rpf commented May 21, 2026

Status

To do:

  • Decide if a caching header needs to be added
  • Decide if any CORS headers need to be added

What's changed?

This syncs Scratch asset library assets into a bucket so we can serve them over a CDN.

I intend to use the same bucket across all the environments- as objects are keyed by their MD5 hash I think this is safe to do. When updating we should run it in production.

Steps to perform before deploying to production

  • Add the required ENV vars to production:
EDITOR_ASSETS_ENDPOINT
EDITOR_ASSETS_ACCESS_KEY_ID
EDITOR_ASSETS_SECRET_ACCESS_KEY
EDITOR_ASSETS_BUCKET

@cla-bot cla-bot Bot added the cla-signed label May 21, 2026
@github-actions
Copy link
Copy Markdown

ghost commented May 21, 2026

Test coverage

91.33% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/26297739172

My next commit will add in another task to the import, having one instance of ScratchAssetImporter per asset, will make easier to cache the asset and not download it twice
@zetter-rpf zetter-rpf force-pushed the save-scratch-assets-to-bucket branch from f59f5d8 to 4108979 Compare May 21, 2026 15:35
Many assets from the asset library are rendered on the page at once which will cause a lot of requests to editor API.

This is being stored in the editor-assets r2 bucket. Note that region isn't used by has to be set to a valid value.
@zetter-rpf zetter-rpf force-pushed the save-scratch-assets-to-bucket branch from 4108979 to ea17a52 Compare May 21, 2026 16:01
@zetter-rpf zetter-rpf temporarily deployed to editor-api-p-save-scrat-omfb8e May 21, 2026 16:01 Inactive
Since these are keyed by their md5 hash we can cache them for a long time (I've chosen 7 days). R2 does add an etag, but the adding this will mean etags won't need to be checked and might enable cloudflare to do more caching.
@zetter-rpf zetter-rpf temporarily deployed to editor-api-p-save-scrat-s7dvb9 May 22, 2026 15:49 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant