Downloadable file
Unanswered
Dutch Smoushond posted this in #help-forum
Dutch SmoushondOP
Hey,
I dynamically create a file in a server side component, but how can I make that available for download on the client?
I dynamically create a file in a server side component, but how can I make that available for download on the client?
6 Replies
Holland Lop
There are several way to do this:
1. return json or other formats and then using Blob on client to create file
2. set proper headers (for ex: Content-Type: image/jpeg) and return raw file
1. return json or other formats and then using Blob on client to create file
2. set proper headers (for ex: Content-Type: image/jpeg) and return raw file
@Holland Lop There are several way to do this:
1. return json or other formats and then using Blob on client to create file
2. set proper headers (for ex: Content-Type: image/jpeg) and return raw file
Dutch SmoushondOP
Its kinda tricky, because I receive a file from the client and then that file is read and used to generate another file to be sent back to the user
Idk if there is any size limitations or other things to look out for
Holland Lop
If you could provide some codes, I can help better, but if you want to use server actions, or api routes you can change config like below:
in api routes:
for server actions in next.config.js
in api routes:
export const config = {
api: {
bodyParser: {
sizeLimit: '2mb' // Set desired value here
}
}
}for server actions in next.config.js
module.exports = {
serverActions: {
bodySizeLimit: '10mb', // Or any value in bytes or a supported format (e.g., '500kb', '3mb')
},
};Where are you hosting?
And how big are the files ?