https://github.com/acearchive/files-worker
A serverless function which hosts artifact files for Ace Archive
https://github.com/acearchive/files-worker
cloudflare-workers serverless
Last synced: about 1 year ago
JSON representation
A serverless function which hosts artifact files for Ace Archive
- Host: GitHub
- URL: https://github.com/acearchive/files-worker
- Owner: acearchive
- License: mit
- Created: 2022-10-03T14:27:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-27T07:31:40.000Z (about 1 year ago)
- Last Synced: 2025-02-27T10:19:40.393Z (about 1 year ago)
- Topics: cloudflare-workers, serverless
- Language: TypeScript
- Homepage:
- Size: 795 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# files-worker
This repo is a [Cloudflare Worker](https://developers.cloudflare.com/workers/)
that serves artifact files hosted on Ace Archive from [Cloudflare
R2](https://developers.cloudflare.com/r2).
Artifact metadata is stored in a [Cloudflare
D1](https://developers.cloudflare.com/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//
```
The artifact metadata in the database is populated by
[acearchive/artifact-submit-action](https://github.com/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](https://multiformats.io/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](https://developers.cloudflare.com/r2/buckets/bucket-locks/)
are used to ensure that files written to R2 cannot be overwritten or deleted.
However, the Cloudflare [Terraform
provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs)
does not seem to support this API as of time of writing, so this step was taken
manually.