In this video, we are going to create a controller for allowing a user to update the cover image or
the profile image and for file upload too.
We have a section where we dive in in details by talking about how we can make use of file upload functionality.
So let's see how we're going to make keys or wait inside this particular application.
For this, we are going to use what is called Cloud Neri.
So let's go ahead and then look in.
If we don't have an account, click on sign up.
So I'm going to click on log in and I'm going to provide my look in details.
So after logging in, this is my dashboard.
Depending on the time of watching this video, the dashboard might change, but a concept is going to
be the same.
So what we need from here is the cloud name the API key and then the API secret for this data.
I would change it later on, so make sure that you use your right details.
So let's click on the cloud name and let's get back to application inside the environment variable.
And here I'm going to create a variable called cloud binary.
Name and is equal to the one I copied.
The next one is going to be the API key, so going to be as cloud generic.
Dash key is equal to this one and the API is secret.
We're going to be as class ordinary and then the secret, and it's equal to that.
The next step is less install the packages that we may need.
So let me shut down the server.
Clear the terminal and install these packages and PMI.
Cloud nine.
And then mortar.
And then the motor storage cloud binary.
And again, for this one too, we have diary details in the previous section of this course.
So let's have a look.
What are these packages?
The first one is called Cloud Neri, and this one is going to help us to be able to save files into
cloud nine and more time is going to allow our server to be able to accept form data by default.
Express does not accept what is called form data.
The next package is called Motor Storage Cloud nine, and this one is going to take away all the complexity
from us.
When you're making use of motor without this package, unless we configure motor, for example, if
you want to accept a specific file type or specific file name about this package is going to make our
life easier.
So let me hit enter the next step is that let's get back to the config folder and here I'm going to
create one file and I'll call this one as Cloudera Dot G is the first step is we are going to require
the cloud ordinary package as cloud ordinary.
And make sure you use Virgin too.
The next package is going to be the cloud storage, so cost equal to required cloud binary.
Storage.
There is mortar cloud, energy storage, and what we want is called cloud energy storage.
All right.
The next step is that we want to make use of this environment variable.
So we need to make use of the environment variable package as required.
And then here make use of dot E and V, and the method is called config.
So with this one, we're going to have the keys inside this file, inside our cloud, ordinary configuration
file.
So let me add a comment here called Configure Cloud.
Nouri ain't going to be as cloud Nouri dot config and here pass in object, provide the cloud name.
The cloud name can be accessed on the process.
Dot EMV, dot the cloud ordinary cloud name is going to be as cloud name.
So let me copy this one and then paste it here.
The next one is let me copy this one because I may need it.
The next one is going to be the API key and the API key can be found on the key when I be a cloud key.
So let me copy this one and let me replace with this one.
The next one going to be the API secretes and it can be found on the API secret.
So going to be process dot EMV and let me have the right variable name here as that.
So let me remove this one and I'm good to go.
The next step is that we are going to create instance of cloud storage and that's going to be cast.
Storage is equal to new and I'm going to make use of cloud storage.
What we got back from the motor storage cloud energy and pass in the configuration.
The first property is going to be the cloud area, which is this, and for this the first property is
going to be the cloud binary, which is this one.
And for this we have added our key.
So we insert here we have the configured cloud wherein the next property is going to be the file type
that we want to accept.
So here is going to be as a cloud format and provide the file type.
I want to accept JPG, jpeg, and then P and G.
The next one is going to be the params, and for this we are going to save the files into a specific
folder inside our dashboard.
So here I'll make use of folder the name of the folder.
I want to save my file.
I'll make this one as block app dash version three and I also want to transform the image, so I'm going
to be transformation.
And I want to accept specific weight of the image.
So I'm going to provide weight.
And the width of this one going to be 500 and then the height also 500.
The next one going to be crop.
And then going to be limits.
All right.
The next step is let's export This one as module.
Don't export is equal to storage.
All right.
The next step is that we are going to pass this one as a meter to any route where I want to upload file.
So let's get into that in the next video.