Next.js Discord

Discord Forum

Is it possible to somehow return a buffer/blob/file from a server action?

Unanswered
American posted this in #help-forum
Open in Discord
AmericanOP
question is in the title πŸ˜„ Now I had to make a route handler just for the file, but I dislike losing the type-safety provided by server actions.

9 Replies

Sure you can whats stopping you?
It needs to be json parsable if I remember correctly
Just convert the file to base64 and then convert it back to a blob
If I remember correctly converting the base64 will make the network transfer about 30% larger over the wire, or something along those lines.
@Jboncz Just convert the file to base64 and then convert it back to a blob
AmericanOP
But I want the bytes, the binary πŸ˜„
Convert it back?
It’s not a one way street
I don’t know of a more streamlined approach.
While utilizing server actions.