Temporary Files in /public
Answered
Tonkinese posted this in #help-forum
TonkineseOP
Hey,
Is there any way storing temporary files in public? And serving them to customers?
I know that they get lost on new deployments, they are just temporary for like 1 minute.
Is there any way storing temporary files in public? And serving them to customers?
I know that they get lost on new deployments, they are just temporary for like 1 minute.
Answered by Rafael Almeida
no, if you want to serve an asset from the
/public
folder it should exist during build time. for runtime file uploading you need to upload it to another service14 Replies
@Tonkinese Hey,
Is there any way storing temporary files in public? And serving them to customers?
I know that they get lost on new deployments, they are just temporary for like 1 minute.
no, if you want to serve an asset from the
/public
folder it should exist during build time. for runtime file uploading you need to upload it to another serviceAnswer
@Rafael Almeida no, if you want to serve an asset from the `/public` folder it should exist during build time. for runtime file uploading you need to upload it to another service
TonkineseOP
Okay sure. Yeah I was planing on hosting a socketio server with next and then generate some TextToSpeech MP3 and play it from the public.
But I guess socketio server isnt even supported with nextjs so
But I guess socketio server isnt even supported with nextjs so
But appreciate you
@Rafael Almeida no, if you want to serve an asset from the `/public` folder it should exist during build time. for runtime file uploading you need to upload it to another service
TonkineseOP
Tried the official docs for nextjs & socket io but that wasnt working. I really need access to the io, but i cant export io because of next.
And then in combination with that issue
And then in combination with that issue
It tells me that I cant export io when in the same file is the const app = next({dev, hostname, port})
Any Idea how i can avoid that?
this requires a custom server which is not really recommended. if you want a socket server its better to build it externally from the next.js server
TonkineseOP
So then it would be better to have the Socket IO and TTS generator seperatly as a microservice for example as docker and then provide the Mp3 URL to the client in nextjs with all required data?
And for everything else where I need to update data I also could fetch an api endpoint every 3 seconds?
Like If i need to display
Title: This is a Title
Rating: 5/5
And then when i need the new data make a api request where i get json?
Title: This is a Title
Rating: 5/5
And then when i need the new data make a api request where i get json?
I guess so
@Rafael Almeida no, if you want to serve an asset from the `/public` folder it should exist during build time. for runtime file uploading you need to upload it to another service
TonkineseOP
Sad that this is not possible, but i guess express does support this. So should be easy to get a microservice working for that!
@Tonkinese So then it would be better to have the Socket IO and TTS generator seperatly as a microservice for example as docker and then provide the Mp3 URL to the client in nextjs with all required data?
yeah probably. I don't really understand the other stuff you are saying, but the idea is if you have a long-running service (like sockets) you need to separate it
TonkineseOP
Okay great to know. Thank you so much for helping!