All right, So everything's awesome.
We installed malter, we set up the configuration.
Now we're able to access the file and we actually nicely have a path.
Now, where's the problem?
Well, you see, even though.
Yes, technically we could provide this string over here to the front end and we'll be able to access
the image.
The problem is going to be when we deploy this project.
So essentially platforms like Render and Heroku, they don't keep those images around if you're familiar
with those platforms, if the application is not used, it goes to sleep.
And essentially once it starts up, this image is no longer there.
So, yes, everything is going to work nicely locally.
But once you push this up to production, the moment your application is going to go to sleep, this
image is going to disappear.
So long story short, we're not going to use the straight up path approach.
Instead, we're going to push our image up to a cloudinary, which essentially is a platform where we
can store, optimize and deliver images.
And once we push it up, we'll get back the URL.
And now the image is going to be stored in a cloudinary So it's always going to be there and we'll just
utilize that URL on the front end as a result.
Essentially, the image is not going to disappear and of course in order to push it up as well as delete
the old image, we'll use the Cloudinary package.
Now, in order to set everything up, yes, we'll have to create another account.
Again, you can do the local approach, but I can tell you right away that the moment you push this
up to production, the image is not going to be persisted.
So pretty much every time your application is going to go to sleep, all of the images are going to
be wiped out.
That's just how those platforms work.
So for starters, we want to navigate over here cloudinary.com.
It's a free account.
So again, we don't need to use the credit card or anything like that.
We want to go for sign up free.
I'm going to go with email then just provide the values.
Click on I'm Not a robot.
Then get started now.
They will ask you to verify your email, so do that.
It might be located in the spam folder.
So click on this link over here.
And once you successfully log in, this is going to be your dashboard.
Now they actually right away provide all of the values that we're looking for.
But I'll also show you another way how we can access them.
So essentially, if we go here with settings.
And then more specifically, we're looking for access keys.
We'll see this value over here.
So this is the API key.
This is the secret.
And also this will be our cloud name.
So those are the three things that we're looking for.
And actually, in my case, I'm just going to showcase how we can generate a new one.
So in here again, we need to provide the password.
And I'm going to call this main course and this is going to be my API key and API secret.
A quick side note.
We can also access all of the values we're going to use in a second.
If we click on the dashboard link, then we want to navigate back to our application more specifically
Dotenv.
And we want to set up these three environment variables.
So right after the JWT ones, we want to create these ones.
And essentially, of course you want to grab the values and like I said, the name is going to be this
one, so let me copy.
Well, set it up over here then.
I want to go with API key.
And then we want to copy the secret as well.
So let me set it up.
And then once we have all of these three values, we want to install the Cloudinary package.
And then in the server I want to go with Cloudinary from Cloudinary.
As I know this is not what we need to do, we just want to go with cloudinary dot config and then pass
in all of these values.
And you know, in order to speed this up, let me just copy.
So again, package is already installed.
We just want to navigate to the server and set it up somewhere here.
So in my case I think I'm going to just import.
Here.
So cloudinary from Cloudinary.
And then let me go to the Dirname and everything and then I'll set it up over here, the config.
So essentially we need to provide the object cloud name API key and API secret.
And if you don't see any errors in the console, we're good to go and we can proceed to the next step.