Skip to content
Permalink
71381e937b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
22 lines (20 sloc) 570 Bytes
import { AwsClient } from "aws4fetch";
export async function onRequestGet(context: RequestContext) {
const attachment = (context.params.id as string[]).join("/");
const aws = new AwsClient({
accessKeyId: context.env.R2_ACCESS_KEY,
secretAccessKey: context.env.R2_SECRET_KEY,
});
return Response.redirect(
(
await aws.sign(
`https://car-crushers.${context.env.R2_ZONE}.r2.cloudflarestorage.com/${attachment}?X-Amz-Expires=1800`,
{
aws: {
signQuery: true,
},
},
)
).url,
);
}