1
00:00:00,780 --> 00:00:08,220
In this video, we are going to create a controller for allowing a user to update the cover image or

2
00:00:08,220 --> 00:00:12,120
the profile image and for file upload too.

3
00:00:12,150 --> 00:00:20,040
We have a section where we dive in in details by talking about how we can make use of file upload functionality.

4
00:00:20,040 --> 00:00:25,080
So let's see how we're going to make keys or wait inside this particular application.

5
00:00:25,530 --> 00:00:29,370
For this, we are going to use what is called Cloud Neri.

6
00:00:29,370 --> 00:00:32,100
So let's go ahead and then look in.

7
00:00:32,130 --> 00:00:34,980
If we don't have an account, click on sign up.

8
00:00:34,980 --> 00:00:40,770
So I'm going to click on log in and I'm going to provide my look in details.

9
00:00:46,780 --> 00:00:50,790
So after logging in, this is my dashboard.

10
00:00:50,800 --> 00:00:57,370
Depending on the time of watching this video, the dashboard might change, but a concept is going to

11
00:00:57,370 --> 00:00:58,420
be the same.

12
00:00:58,540 --> 00:01:06,520
So what we need from here is the cloud name the API key and then the API secret for this data.

13
00:01:06,820 --> 00:01:11,990
I would change it later on, so make sure that you use your right details.

14
00:01:12,040 --> 00:01:20,200
So let's click on the cloud name and let's get back to application inside the environment variable.

15
00:01:20,410 --> 00:01:24,600
And here I'm going to create a variable called cloud binary.

16
00:01:26,590 --> 00:01:30,460
Name and is equal to the one I copied.

17
00:01:30,910 --> 00:01:36,890
The next one is going to be the API key, so going to be as cloud generic.

18
00:01:39,910 --> 00:01:46,300
Dash key is equal to this one and the API is secret.

19
00:01:46,510 --> 00:01:53,860
We're going to be as class ordinary and then the secret, and it's equal to that.

20
00:01:53,890 --> 00:01:58,640
The next step is less install the packages that we may need.

21
00:01:58,660 --> 00:02:01,710
So let me shut down the server.

22
00:02:01,730 --> 00:02:07,470
Clear the terminal and install these packages and PMI.

23
00:02:07,810 --> 00:02:09,160
Cloud nine.

24
00:02:09,910 --> 00:02:11,770
And then mortar.

25
00:02:11,770 --> 00:02:16,210
And then the motor storage cloud binary.

26
00:02:17,560 --> 00:02:23,190
And again, for this one too, we have diary details in the previous section of this course.

27
00:02:23,200 --> 00:02:24,480
So let's have a look.

28
00:02:24,490 --> 00:02:26,260
What are these packages?

29
00:02:26,440 --> 00:02:32,860
The first one is called Cloud Neri, and this one is going to help us to be able to save files into

30
00:02:32,860 --> 00:02:41,020
cloud nine and more time is going to allow our server to be able to accept form data by default.

31
00:02:41,020 --> 00:02:44,530
Express does not accept what is called form data.

32
00:02:44,680 --> 00:02:52,300
The next package is called Motor Storage Cloud nine, and this one is going to take away all the complexity

33
00:02:52,300 --> 00:02:53,020
from us.

34
00:02:53,020 --> 00:02:59,230
When you're making use of motor without this package, unless we configure motor, for example, if

35
00:02:59,230 --> 00:03:06,820
you want to accept a specific file type or specific file name about this package is going to make our

36
00:03:06,820 --> 00:03:07,600
life easier.

37
00:03:07,600 --> 00:03:15,730
So let me hit enter the next step is that let's get back to the config folder and here I'm going to

38
00:03:15,730 --> 00:03:26,110
create one file and I'll call this one as Cloudera Dot G is the first step is we are going to require

39
00:03:26,110 --> 00:03:30,160
the cloud ordinary package as cloud ordinary.

40
00:03:32,780 --> 00:03:35,900
And make sure you use Virgin too.

41
00:03:36,350 --> 00:03:47,480
The next package is going to be the cloud storage, so cost equal to required cloud binary.

42
00:03:49,420 --> 00:03:49,960
Storage.

43
00:03:49,960 --> 00:03:55,600
There is mortar cloud, energy storage, and what we want is called cloud energy storage.

44
00:03:55,930 --> 00:03:57,000
All right.

45
00:03:57,010 --> 00:04:02,040
The next step is that we want to make use of this environment variable.

46
00:04:02,050 --> 00:04:07,210
So we need to make use of the environment variable package as required.

47
00:04:07,360 --> 00:04:13,710
And then here make use of dot E and V, and the method is called config.

48
00:04:13,720 --> 00:04:21,190
So with this one, we're going to have the keys inside this file, inside our cloud, ordinary configuration

49
00:04:21,190 --> 00:04:21,820
file.

50
00:04:21,910 --> 00:04:25,450
So let me add a comment here called Configure Cloud.

51
00:04:25,480 --> 00:04:35,620
Nouri ain't going to be as cloud Nouri dot config and here pass in object, provide the cloud name.

52
00:04:35,620 --> 00:04:39,130
The cloud name can be accessed on the process.

53
00:04:39,130 --> 00:04:45,910
Dot EMV, dot the cloud ordinary cloud name is going to be as cloud name.

54
00:04:45,910 --> 00:04:49,930
So let me copy this one and then paste it here.

55
00:04:50,050 --> 00:04:53,860
The next one is let me copy this one because I may need it.

56
00:04:53,890 --> 00:05:02,590
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.

57
00:05:02,590 --> 00:05:07,000
So let me copy this one and let me replace with this one.

58
00:05:07,120 --> 00:05:15,200
The next one going to be the API secretes and it can be found on the API secret.

59
00:05:15,220 --> 00:05:23,260
So going to be process dot EMV and let me have the right variable name here as that.

60
00:05:23,260 --> 00:05:28,030
So let me remove this one and I'm good to go.

61
00:05:28,270 --> 00:05:36,460
The next step is that we are going to create instance of cloud storage and that's going to be cast.

62
00:05:37,000 --> 00:05:43,360
Storage is equal to new and I'm going to make use of cloud storage.

63
00:05:43,510 --> 00:05:49,720
What we got back from the motor storage cloud energy and pass in the configuration.

64
00:05:49,900 --> 00:05:56,230
The first property is going to be the cloud area, which is this, and for this the first property is

65
00:05:56,230 --> 00:06:00,190
going to be the cloud binary, which is this one.

66
00:06:00,640 --> 00:06:03,310
And for this we have added our key.

67
00:06:03,310 --> 00:06:10,720
So we insert here we have the configured cloud wherein the next property is going to be the file type

68
00:06:10,720 --> 00:06:12,550
that we want to accept.

69
00:06:12,550 --> 00:06:19,840
So here is going to be as a cloud format and provide the file type.

70
00:06:19,840 --> 00:06:26,460
I want to accept JPG, jpeg, and then P and G.

71
00:06:26,950 --> 00:06:35,290
The next one is going to be the params, and for this we are going to save the files into a specific

72
00:06:35,290 --> 00:06:37,570
folder inside our dashboard.

73
00:06:37,600 --> 00:06:41,800
So here I'll make use of folder the name of the folder.

74
00:06:41,800 --> 00:06:43,390
I want to save my file.

75
00:06:43,390 --> 00:06:52,780
I'll make this one as block app dash version three and I also want to transform the image, so I'm going

76
00:06:52,780 --> 00:06:54,640
to be transformation.

77
00:06:57,150 --> 00:07:01,590
And I want to accept specific weight of the image.

78
00:07:01,590 --> 00:07:03,480
So I'm going to provide weight.

79
00:07:05,600 --> 00:07:12,110
And the width of this one going to be 500 and then the height also 500.

80
00:07:12,740 --> 00:07:15,290
The next one going to be crop.

81
00:07:16,010 --> 00:07:18,200
And then going to be limits.

82
00:07:18,680 --> 00:07:19,400
All right.

83
00:07:19,610 --> 00:07:24,050
The next step is let's export This one as module.

84
00:07:24,050 --> 00:07:26,930
Don't export is equal to storage.

85
00:07:27,990 --> 00:07:28,850
All right.

86
00:07:29,150 --> 00:07:37,430
The next step is that we are going to pass this one as a meter to any route where I want to upload file.

87
00:07:37,430 --> 00:07:39,980
So let's get into that in the next video.

