feat: download document via api v2 (#1918)

adds document download functionality to the API v2, returning
pre-signed S3 URLs that provide secure, time-limited access to document
files similar to what happens in the API v1 download document endpoint.
This commit is contained in:
Ephraim Duncan
2025-08-05 02:29:21 +00:00
committed by GitHub
parent 5689cd1538
commit 9b01a2318f
5 changed files with 123 additions and 18 deletions

View File

@ -1,6 +1,5 @@
import type { Document } from '@prisma/client';
import { DocumentDataType } from '@prisma/client';
import { TRPCError } from '@trpc/server';
import { getServerLimits } from '@documenso/ee/server-only/limits/server';
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
@ -556,9 +555,9 @@ export const templateRouter = router({
});
if (csv.length > 4 * 1024 * 1024) {
throw new TRPCError({
code: 'BAD_REQUEST',
throw new AppError(AppErrorCode.LIMIT_EXCEEDED, {
message: 'File size exceeds 4MB limit',
statusCode: 400,
});
}
@ -569,8 +568,7 @@ export const templateRouter = router({
});
if (!template) {
throw new TRPCError({
code: 'NOT_FOUND',
throw new AppError(AppErrorCode.NOT_FOUND, {
message: 'Template not found',
});
}