1
00:00:07,610 --> 00:00:08,990
Welcome back.

2
00:00:09,020 --> 00:00:12,410
Let's get started with file upload.

3
00:00:12,980 --> 00:00:20,360
Unlucky for us by default, express does not support file upload.

4
00:00:20,390 --> 00:00:28,520
That is for data and we can configure Express to accept what is called form data.

5
00:00:29,030 --> 00:00:36,260
Until this point, all the data that we sent our server are all JSON data like texts.

6
00:00:36,410 --> 00:00:40,160
So how are we going to send files to our server?

7
00:00:40,490 --> 00:00:41,150
Good.

8
00:00:41,150 --> 00:00:49,310
And lucky for us we have a package called Morta and we are going to use more to package to be able to

9
00:00:49,310 --> 00:00:52,940
allow express to accept for data.

10
00:00:53,240 --> 00:00:58,160
By the end of this section, this is a project that we are going to create.

11
00:00:58,190 --> 00:01:06,100
We will allow a user to be able to upload image from their browser and also fetch all images.

12
00:01:06,110 --> 00:01:08,060
So let's get started.

13
00:01:08,180 --> 00:01:16,030
The first step is I will show you how we can use Postman or create the API to upload images.

14
00:01:16,040 --> 00:01:23,630
And after that I will show you how we can use the form also to upload images and I'm going to show you

15
00:01:23,630 --> 00:01:26,240
two ways of uploading images.

16
00:01:26,270 --> 00:01:35,390
First is we are going to learn how we can use motor to upload images onto the file system and then after

17
00:01:35,390 --> 00:01:41,040
that we go ahead and use Cloud Neri and save images into Cloud Neri.

18
00:01:41,060 --> 00:01:45,800
So let's get started with motor before we continue.

19
00:01:45,830 --> 00:01:53,990
I have provided a sample project for you with some starter code and I work through the folders here.

20
00:01:54,020 --> 00:02:01,670
So if you open the config, you can see that this is a configuration for our MongoDB connection and

21
00:02:01,670 --> 00:02:08,840
for this one we have talked about it before and I have given you my free connection string, but I can

22
00:02:08,840 --> 00:02:10,370
change it at any time.

23
00:02:10,550 --> 00:02:16,820
I'm advising you to use your own connection string and when you get back to Cloud Neri, we are going

24
00:02:16,820 --> 00:02:19,620
to save the strings into our MongoDB.

25
00:02:20,150 --> 00:02:24,350
That is why we have this function to connect to MongoDB.

26
00:02:24,500 --> 00:02:31,280
And then inside the model, that's where we are going to save the images into our database inside the

27
00:02:31,280 --> 00:02:33,890
public container, the CSS for the project.

28
00:02:33,890 --> 00:02:41,540
And then the view is contains the templates and purchase content, the navigation links for this once

29
00:02:41,540 --> 00:02:49,040
we have covered them in details and if you open the server file, that's where we are going to write

30
00:02:49,040 --> 00:02:55,300
the code where I made a mistake to add this one so you can go ahead and delete this file called Indexed

31
00:02:55,310 --> 00:02:56,180
or HTML.

32
00:02:56,210 --> 00:02:57,050
We don't need it.

33
00:02:57,050 --> 00:03:05,570
We are going to work on the server dot js file so make sure that everything is correct.

34
00:03:05,570 --> 00:03:12,350
So open your terminal and start the server to make sure that everything is working.

35
00:03:12,380 --> 00:03:14,720
Then we can get started.

36
00:03:14,750 --> 00:03:15,380
All right.

37
00:03:15,380 --> 00:03:19,880
You can see that the server is up and running the next video.

38
00:03:19,880 --> 00:03:22,670
Let's get started with the file upload.

