Sending file (image/video) to trpc procedure
Hi anyone have a clue on how i can send an image/video to trpc procedure to upload it to google drive from there
i tried to do it directly from front but since i need access to fs i couldnt
if you have another way to save a video to google drive in nextjs i would love to know it
23 Replies
You don't
Idk how this would even work from the client lel
But tRPC doesn't take files only serializable content
so we can't upload a video to the cloud using T3 stack xD ?
You can
how would you do it
Client -> tRPC -> AWS -> tRPC -> Client -> S3 Bucket
trpc asks for a presigned url, gives it to the user, and the user sends it from their machine
theres a guide on specifically t3+s3buckets and presigned urls you can look it up
found this im gonna read about it
https://github.com/nramkissoon/t3-s3
GitHub
GitHub - nramkissoon/t3-s3: Example create-t3-app with AWS S3 presi...
Example create-t3-app with AWS S3 presigned URL integration - GitHub - nramkissoon/t3-s3: Example create-t3-app with AWS S3 presigned URL integration
currently trpc is using json or url encoded payloads
so you can't send files
yea that what i found
but there is a rfc about using FormData as a transport mechanism
ugh honestly i don't think tRPC is ready for prod
why is that?
lol
having to send a file in a base64 encode is not prod ready for me
how much of your job is sending files from the frontend?
Why do you have to send a file at all to your backend
outside of formdata
i dont think there is a nice way of sending files nicely
I still don’t see why someone would need to send files to their backend
Or rather their endpoint
Yeah don't lmao
Its not what trpc is made for
File uploading without s3 or similar
Yes I get that part 😂 but when does that apply
ugh of the top of my head, when you just want to proccess some data inside a upload quickly without all the hastle of s3, or maybe your downloading files from an external source ( not related to a frontend )
How about validating files, how do you approach this guys? Do you allow any files?
You can already restrict filters in the frontend by specifying allowed file types in the upload input. Additionally there’s configuration on S3 which allows you to restrict file types entering a bucket