K
K
TTCTheo's Typesafe Cult
Created by K on 12/13/2023 in #questions
Does anyone know how to speed up presigning S3 URLs?
I'm working on a toy project where users upload content, and I noticed that it takes forever to load an image, and the bottleneck seems to be in creating a presigned URL on my machine. There could be other faults in my code or optimizations I could make, but some info: - I'm testing this on an M2 Macbook Air - I have a trpc procedure which generates the presigned URL and returns it to the client - I'm using getSignedUrl from @aws-sdk/s3-request-presigner - It takes over half a second to run getSignedUrl based on my tests Is there some pitfall I'm falling into? Is there a better alternative?
const params: GetObjectCommandInput = {
Bucket: env.S3_BUCKET_NAME,
Key: key,
}

const client = new S3Client({ region: env.S3_REGION });
const command = new GetObjectCommand(params);
const presignedURL = await getSignedUrl(client, command, { expiresIn: 3600 });
const params: GetObjectCommandInput = {
Bucket: env.S3_BUCKET_NAME,
Key: key,
}

const client = new S3Client({ region: env.S3_REGION });
const command = new GetObjectCommand(params);
const presignedURL = await getSignedUrl(client, command, { expiresIn: 3600 });
inb4 use UploadThing, I'm using this project to learn, otherwise I'd be happy to.
5 replies