Taylor
Taylor
TTCTheo's Typesafe Cult
Created by Taylor on 12/10/2024 in #questions
How to upload a PDF file to uploadthing from a route.ts file
export async function uploadFileToProfile(
pdfBuffer: Uint8Array<ArrayBufferLike>,
uniqueMetadataId: string,
) {
const { userId } = await auth();

if (!userId) {
return {
success: false,
error: "Unauthorized",
};
}

const blob = new Blob([pdfBuffer]);
const file = new File([blob], `${uniqueMetadataId}.pdf`);

const result = await utapi.uploadFiles(file);
export async function uploadFileToProfile(
pdfBuffer: Uint8Array<ArrayBufferLike>,
uniqueMetadataId: string,
) {
const { userId } = await auth();

if (!userId) {
return {
success: false,
error: "Unauthorized",
};
}

const blob = new Blob([pdfBuffer]);
const file = new File([blob], `${uniqueMetadataId}.pdf`);

const result = await utapi.uploadFiles(file);
This function is being called from a route.ts file. Im getting a vague error relating to some regex match in uploadthings source: 207 | // Pull out numbers from strings like 6.0.0, ^6.4, ~6.4.0 208 | const semverRegex = /(\d+).?(\d+)?.?(\d+)?/;
209 | const requiredMatch = required.match(semverRegex);
| ^ 210 | if (!requiredMatch?.[0]) { 211 | throw new Error(Invalid semver requirement: ${required}); 212 | } { From the documentation it seems like this is done very similarly with FormData files in an in-component server action, and I dont see what the difference would be here.
3 replies
TTCTheo's Typesafe Cult
Created by Taylor on 3/26/2024 in #questions
Dictating how webpack resolves dependencies
I am building a project that uses webpack and babel to transpile user-submitted code. Im doing this in a serverless env using nextjs/vercel. Im running into issues where webpack is trying to resolve dependencies that it cant find because its running in a serverless env and is searching for them using my projects directory instead of the different directory thats built by next. Is there a way in my webpack config to specify where to start finding these deps using process.cwd() (what vercel suggests using instead of __dirname)? This does seem like a odd question and I don't have a full understanding of whats actually going on here. Ive looked through webpacks docs and the webpack config types.d.ts file a ton trying to find a fix for this but have come up short
4 replies
TTCTheo's Typesafe Cult
Created by Taylor on 1/4/2024 in #questions
Module not found when using @babel in a next serverless function
No description
3 replies
TTCTheo's Typesafe Cult
Created by Taylor on 5/18/2023 in #questions
Auto populating new tables on user sign in
14 replies
TTCTheo's Typesafe Cult
Created by Taylor on 3/20/2023 in #questions
Random/inconsistent TRPCClientErrors in local environment.
6 replies