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
barry
barry2y ago
You don't
barry
barry2y ago
Idk how this would even work from the client lel But tRPC doesn't take files only serializable content
H
HOP2y ago
so we can't upload a video to the cloud using T3 stack xD ?
barry
barry2y ago
You can
H
HOP2y ago
how would you do it
barry
barry2y ago
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
H
HOP2y ago
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
Neto
Neto2y ago
currently trpc is using json or url encoded payloads so you can't send files
H
HOP2y ago
yea that what i found
Neto
Neto2y ago
but there is a rfc about using FormData as a transport mechanism
H
HOP2y ago
ugh honestly i don't think tRPC is ready for prod
Neto
Neto2y ago
why is that? lol
H
HOP2y ago
having to send a file in a base64 encode is not prod ready for me
Neto
Neto2y ago
how much of your job is sending files from the frontend?
barry
barry2y ago
Why do you have to send a file at all to your backend
Neto
Neto2y ago
outside of formdata i dont think there is a nice way of sending files nicely
barry
barry2y ago
I still don’t see why someone would need to send files to their backend Or rather their endpoint
Finn
Finn2y ago
Yeah don't lmao Its not what trpc is made for File uploading without s3 or similar
barry
barry2y ago
Yes I get that part 😂 but when does that apply
Finn
Finn2y ago
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 )
Jaaneek
Jaaneek2y ago
How about validating files, how do you approach this guys? Do you allow any files?
jingleberry
jingleberry2y ago
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
Want results from more Discord servers?
Add your server