T
TanStack12mo ago
like-gold

Sending a file via a server function possible?

I am making an application using Start, and one of the requirements is uploading files. Is it possible to send a file through a server function? I know things like Date's cannot be, but this seems like an important use-case in Start
5 Replies
extended-salmon
extended-salmon12mo ago
Yes, should work. Though I haven’t tested. If you return a Response, it won’t do any of the serialization stuff So you should be fine to send and return streams and while responses.
like-gold
like-goldOP12mo ago
Ahhhh. Oops. I meant the reverse. Sending files to a server function. I imagine I can just do this with an API route, if needed, but was wondering if a server fn could work
extended-salmon
extended-salmon12mo ago
Yep. If you send a Request or ReadableStream or FormData, it will post to the endpoint via fetch as normal. Under the hood, it’s just a fetch call
like-gold
like-goldOP12mo ago
Will try that, thanks Tanner!
extended-salmon
extended-salmon11mo ago
You bet! Good luck!

Did you find this page helpful?