Skip to content

LegacyPipeline

Source: src/Cloudflare/Pipelines/LegacyPipeline.ts

A legacy Cloudflare Pipeline — the original HTTP-ingest → R2 batch product (/accounts/{account}/pipelines).

A legacy pipeline accepts JSON events over HTTP (and/or a Worker pipelines binding) and batches them into an R2 bucket using S3-compatible credentials.

HTTP ingest into R2

The S3-compatible credentials are derived from a Cloudflare API token: the access key id is the token id and the secret is the SHA-256 hex digest of the token value.

const bucket = yield* Cloudflare.R2Bucket("events", {});
const pipeline = yield* Cloudflare.LegacyPipeline("ingest", {
destination: {
bucket: bucket.bucketName,
credentials: {
accessKeyId: alchemy.secret.env.R2_ACCESS_KEY_ID,
secretAccessKey: alchemy.secret.env.R2_SECRET_ACCESS_KEY,
},
},
});
// POST events to pipeline.endpoint

Tuned batching and CORS

const pipeline = yield* Cloudflare.LegacyPipeline("ingest", {
source: [
{ type: "http", cors: { origins: ["https://example.com"] } },
],
destination: {
bucket: bucket.bucketName,
credentials,
batch: { maxDurationS: 10, maxRows: 1000 },
compression: "gzip",
prefix: "ingest",
},
});