feat: add file viewer and downloads

This commit is contained in:
Henry
2025-11-14 22:15:28 +00:00
parent 070fc373f2
commit f495ca3505
9 changed files with 286 additions and 35 deletions

View File

@@ -197,7 +197,11 @@ export const attachmentRouter = createTRPCRouter({
code: "INTERNAL_SERVER_ERROR",
});
const url = await generateDownloadUrl(bucket, attachment.s3Key, 3600);
const url = await generateDownloadUrl(
bucket,
attachment.s3Key,
86400, // 24 hours expiration
);
return { url, filename: attachment.originalFilename };
}),

View File

@@ -586,6 +586,7 @@ export const cardRouter = createTRPCRouter({
contentType: string;
s3Key: string;
originalFilename: string | null;
size?: number | null;
url: string | null;
}[];
}
@@ -634,6 +635,7 @@ export const cardRouter = createTRPCRouter({
contentType: string;
s3Key: string;
originalFilename: string | null;
size?: number | null;
}[];
const attachmentsWithUrls = await Promise.all(
@@ -643,6 +645,7 @@ export const cardRouter = createTRPCRouter({
contentType: attachment.contentType,
s3Key: attachment.s3Key,
originalFilename: attachment.originalFilename,
size: attachment.size,
};
if (!bucket || !attachment.s3Key) {
return { ...base, url: null };
@@ -651,7 +654,7 @@ export const cardRouter = createTRPCRouter({
const url = await generateDownloadUrl(
bucket,
attachment.s3Key,
3600, // 1 hour expiration
86400, // 24 hours expiration
);
return { ...base, url };
} catch {