Skip to content

A serverless function which hosts artifact files for Ace Archive

License

Notifications You must be signed in to change notification settings

acearchive/files-worker

Repository files navigation

files-worker

This repo is a Cloudflare Worker that serves artifact files hosted on Ace Archive from Cloudflare R2.

Artifact metadata is stored in a Cloudflare D1 SQLite database. This worker handles incoming GET and HEAD requests to https://files.acearchive.lgbt, reads the metadata for the artifact from the database, and then serves the file contents from R2.

This worker handles requests of the form:

https://files.acearchive.lgbt/artifacts/<artifact_slug>/<file_name>

The artifact metadata in the database is populated by acearchive/artifact-submit-action. Requesting this metadata in this worker is necessary because objects in R2 are keyed by their hash (more specifically a multihash), so we need to get the hash of the file first.

HTTP range requests and conditional requests are supported, and ETag and Last-Modified headers are returned for caching.

R2 bucket locks are used to ensure that files written to R2 cannot be overwritten or deleted. However, the Cloudflare Terraform provider does not seem to support this API as of time of writing, so this step was taken manually.

About

A serverless function which hosts artifact files for Ace Archive

Topics

Resources

License

Stars

Watchers

Forks