Serverless function create file

Just a quick question for a noob who is very new to Netlify.

I have an idea that includes a serverless function to create an mp3 file, which afterward the user can download to their computer.

Therefore is my question, can a serverless function create a file that gets stored on the website, I think in the Large Media section. Or should I go out and get an Amazon S3 server?

Thanks for the help.
Best Regards Fredrik Johansen.

Yes, you can create files, however I’d advise not to. Serverless Functions are limited to 10 sec of execution time and even if you upgrade, you’d get a maximum of 26. Generating a file within that time might be difficult. You should instead take a look at background functions. They can run for 15 mins.

Moving on, if you want the user to be able to download, you’d have to store the file externally like you said, Amazon S3. This is because, you can’t add an individual file to your Netlify webite, you always have to upload the entire website which won’t be possible for functions. As far as I know, you can only return JSON values from functions, so you probably can’t send the file for download over Netlify.

Ohhh okay. Thanks for clarifying both the download option and the upload thing. It all makes a lot of sense now. I’m going to try out the Amazon S3 server to host my files, then making the serverless function as fast as possible :joy: