#Hey guys, what is better way to store an

1 messages · Page 1 of 1 (latest)

twilit axle
#

In my previous case, I stored it in public images folder and recorded their paths to the db in Node.js/Express.js app.

calm tulip
#

Yeah

#

But how do you do that ?

#

I mean, how do you store on the public folder ?

twilit axle
#

What technical stack are you using in your backend?

calm tulip
#

Nextjs14 app directory

#

Server actions

#

Im not using api routes

#

mongoose

twilit axle
#

hey

#

I think you have to research about the concept of frontend and backend first

calm tulip
#

Hahaha

#

Im using nextjs default server

#

Im managing front end and backend there

#

yeah

#

but im using nodejs

#

xD

twilit axle
#

yeah, that's what I was concerned with

#

As you said, it would be Node.js/Express app, right?

#

since it's next.js's default support

calm tulip
#

Is it the same ? Or they go both ?

#

Yeah sure

#

thats it

#

node / express

twilit axle
#

But in my past, I used next in frontend while using Ruby on Rails in backend

#

so that was why I asked

calm tulip
#

Yeah sure

#

I was using react and laravel

#

Just migrated to nextjs after seeing server actions

#

So tell me

#

How can i store it on the public folder ?

#

I have to use some package ?

calm tulip
still ingot
#

The best practice for storing images, especially if you're expecting to store a lot, is to store the binary file in a bucket store (GCP/AWS S3), and just store that URL in your DB.

calm tulip
#

Can i use aws s3 for free ?

#

I mean i want something to work with locally

#

before prod

still ingot
#

Yeah, there's a very generous free tier.

calm tulip
#

Okay cool

#

So from nextjs i have to store the image on aws

#

And return url to store it in db

#

Is there package for that ?

still ingot
still ingot
#

You can also use Vercel's blob storage which is easier to setup.

However, be careful when using it with local development as the requests won't be cached and you'll very quickly hit the data transfer limits.

calm tulip
#

I see

#

Yeah sure dont worry