1
00:00:00,180 --> 00:00:07,200
All right, and once we're clear that when we are creating a product for the image, we need to provide

2
00:00:07,200 --> 00:00:13,710
a path where the image is located and it's not like we can just willy nilly guess the value.

3
00:00:14,010 --> 00:00:17,930
Now, let's switch gears and focus on upload image.

4
00:00:18,390 --> 00:00:24,300
So first we have the route, we have product upload and we're going with post method.

5
00:00:24,630 --> 00:00:28,520
And then in the body we're looking for form data.

6
00:00:28,740 --> 00:00:32,840
So we're not looking fora like we did and create product in here.

7
00:00:32,850 --> 00:00:34,880
We're looking for form data.

8
00:00:35,220 --> 00:00:38,640
And yes, I'll show you how that looks like on the front end as well.

9
00:00:39,000 --> 00:00:45,300
First, I just want to showcase how I can send files and our cache images from the postman.

10
00:00:45,550 --> 00:00:45,880
Sure.

11
00:00:45,900 --> 00:00:50,480
Looking for form data and noticed here where we have the key.

12
00:00:50,670 --> 00:00:53,850
We don't want to go with text, we want to go with file.

13
00:00:54,300 --> 00:00:55,830
Then we need to come up with a name.

14
00:00:56,010 --> 00:00:59,840
And in my case, I'm going to go with image and check it out.

15
00:00:59,970 --> 00:01:07,470
We have here these select files, so we just click and I can pick any file you want from your file system.

16
00:01:07,800 --> 00:01:10,010
So if you want to go to your downloads, you can do that.

17
00:01:10,020 --> 00:01:17,610
In my case, like I showed you in the previous video, I moved images from the folder to the desktop

18
00:01:17,760 --> 00:01:20,790
and now I can access any images from the folder.

19
00:01:21,120 --> 00:01:24,340
And I'm just going to go with the first one will open this one.

20
00:01:24,480 --> 00:01:27,210
So now we are storing this image here.

21
00:01:27,450 --> 00:01:35,310
And before we send it, I want to go back to my uploads controller and I want to console log the request

22
00:01:35,520 --> 00:01:37,880
just so you can see what is happening.

23
00:01:38,160 --> 00:01:42,270
So let's go here with a log truck and I'm not going to go with body.

24
00:01:42,270 --> 00:01:44,340
I'll show you that it is actually empty.

25
00:01:44,730 --> 00:01:50,130
And then let's send it from the postman and we should see the response and product image.

26
00:01:50,140 --> 00:01:51,300
Yep, that's great.

27
00:01:51,300 --> 00:01:53,570
But that's not actually what we're looking for.

28
00:01:53,940 --> 00:01:55,890
But I'm looking for is this one request.

29
00:01:56,250 --> 00:01:57,120
And let's start here.

30
00:01:58,010 --> 00:01:59,580
Notice how the body is empty.

31
00:01:59,960 --> 00:02:08,509
That's why we'll have to use additional package by the name of Xpress file upload to grab that image

32
00:02:08,509 --> 00:02:15,680
data and actually pass it so we can do something with it, because it's not like we're traditional setup

33
00:02:16,010 --> 00:02:23,550
where we use Express Dodgson, where I simply can just take this data and it's available in the body.

34
00:02:23,720 --> 00:02:26,150
Now, fortunately, that's not how it works.

35
00:02:26,510 --> 00:02:32,850
So if we keep scrolling and you'll have to scroll quite a bit, that's a little bit annoying.

36
00:02:33,230 --> 00:02:36,860
You'll notice over here we need to have access to this one.

37
00:02:37,070 --> 00:02:41,200
And that's why I will use this package in the following video.

38
00:02:41,660 --> 00:02:44,040
Just understand that from the postman.

39
00:02:44,090 --> 00:02:52,040
If you want to send a file, just look for the form data here and then pass in the file instead of text

40
00:02:52,370 --> 00:02:54,410
and then just pick any file you want.

41
00:02:54,750 --> 00:02:58,160
And then once you send, it's not going to be available by default.

42
00:02:58,610 --> 00:03:04,850
But once we start implementing, this package will have access to the file and then we can start doing

43
00:03:04,850 --> 00:03:08,180
something meaningful, meaning storing it on a server.

44
00:03:08,390 --> 00:03:14,780
And then eventually we'll send back the response with a correct path on the server.

