Next.js Discord

Discord Forum

Vercel dont find dir.

Answered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
Hello, i am trying to let my api server to add file to "/public/images" for save (as storage).
And when i tried i get it:
[Error: ENOENT: no such file or directory, mkdir '/public'] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: '/public'
}

How im going to fix it?
Answered by joulev
You can’t save files to public. You have to use object storage services like cloudflare r2 or aws s3
View full answer

14 Replies

Answer
@joulev You can’t save files to public. You have to use object storage services like cloudflare r2 or aws s3
American black bearOP
Is cloudflare r2 free or paid?
I know aws s3 is paid
@American black bear Is cloudflare r2 free or paid?
No object storage services are free if you use it a lot. Many services have free tiers. R2 has a free tier
American black bearOP
Oh
@joulev No object storage services are free if you use it a lot. Many services have free tiers. R2 has a free tier
American black bearOP
And what is "/tmp? That let to save on it
@American black bear And what is "/tmp? That let to save on it
/tmp is for temporary file storage as the name implies. it will be destroyed after the route handler/server action finishes. you cannot use it for persistent storage.
American black bearOP
Oh
if you just need temporary storage then you can use it. for example if you want to parse the file on the server to feed into a LLM, then you can use it
to store users' profile pictures then no, you can't use it because it is gone as soon as the route finishes
American black bearOP
All i am tryinf that when the file save in dir so i can to do "domain.xyz/uploads/{file}.mp4"
trying*
then no. you need to use cloudflare r2 or similar services. /tmp is not for that
American black bearOP
Oh okay