You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a sveltekit app that lets the user upload images to the /static/img directory using writeFile (fs) and access it right away from their homepage.
It works fine when I run it locally but when I deploy the app to coolify the images in the /static/img directory are not persistent, meaning they get deleted after each redeployment.
I tried making it persistent by mounting a volume, which worked, but I can't really access the images in that directory from my homepage during runtime (e.g. by using <img src="/img/test.jpg" /> or visiting their direct url at https://website.com/img/test.jpg).
I'm new to docker and coolify and I've been searching for a solution for hours but can't figure out how I should do it.
I don't want to use an image CDN.
This is my /api/upload/server.js file that uploads the images to the /static/img directory:
import{writeFile}from"fs"exportasyncfunctionPOST({ request }){constdata=awaitrequest.json()const{ code, image }=datawriteFile(`static/img/${code}.jpg`,image,"base64",(err)=>{if(err)console.log(err)else{console.log("File written successfully")}})}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a sveltekit app that lets the user upload images to the
/static/img
directory using writeFile (fs) and access it right away from their homepage.It works fine when I run it locally but when I deploy the app to coolify the images in the
/static/img
directory are not persistent, meaning they get deleted after each redeployment.I tried making it persistent by mounting a volume, which worked, but I can't really access the images in that directory from my homepage during runtime (e.g. by using
<img src="/img/test.jpg" />
or visiting their direct url at https://website.com/img/test.jpg).I'm new to docker and coolify and I've been searching for a solution for hours but can't figure out how I should do it.
I don't want to use an image CDN.
This is my
/api/upload/server.js
file that uploads the images to the/static/img
directory:Beta Was this translation helpful? Give feedback.
All reactions