feat: migrate nextjs to rr7

This commit is contained in:
David Nguyen
2025-01-02 15:33:37 +11:00
parent 9183f668d3
commit 383b5f78f0
898 changed files with 31175 additions and 24615 deletions

View File

@ -1,8 +1,7 @@
import { DocumentDataType } from '@prisma/client';
import { base64 } from '@scure/base';
import { match } from 'ts-pattern';
import { DocumentDataType } from '@documenso/prisma/client';
export type GetFileOptions = {
type: DocumentDataType;
data: string;
@ -31,9 +30,23 @@ const getFileFromBytes64 = (data: string) => {
};
const getFileFromS3 = async (key: string) => {
const { getPresignGetUrl } = await import('./server-actions');
const getPresignedUrlResponse = await fetch(`/api/files/presigned-get-url`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
key,
}),
});
const { url } = await getPresignGetUrl(key);
if (!getPresignedUrlResponse.ok) {
throw new Error(
`Failed to get presigned url with key "${key}", failed with status code ${getPresignedUrlResponse.status}`,
);
}
const { url } = await getPresignedUrlResponse.json();
const response = await fetch(url, {
method: 'GET',