1
00:00:00,120 --> 00:00:08,430
In this video we are going to do uploading a file into Amazon S3 bucket with using a tablet SDK libraries.

2
00:00:08,520 --> 00:00:11,790
For that purpose, we are going to use PWD Object Command.

3
00:00:12,180 --> 00:00:18,420
Please open the widgets to the code and this time I'm going to create an index HTML under the r lecture

4
00:00:18,450 --> 00:00:23,010
in order to upload this file into our newly created bucket.

5
00:00:23,010 --> 00:00:29,130
And here you can see that I have created a separate JavaScript file, which is the upload object JS

6
00:00:29,130 --> 00:00:32,520
file, which we will perform the actual logic in here.

7
00:00:32,760 --> 00:00:36,870
But before that, let me check the note list bucket.

8
00:00:36,890 --> 00:00:43,470
JS We have already implement this bucket JS And if you hit the enter, you can see that in the last

9
00:00:43,470 --> 00:00:50,370
video we have created this new bucket from HDC and this time we will upload these index HTML file into

10
00:00:50,370 --> 00:00:54,780
this bucket team for that purpose before we start the implementation.

11
00:00:54,780 --> 00:00:59,850
It is good to implement an install required NPM package package.

12
00:00:59,880 --> 00:01:03,750
In order to do that, you can see in here we are going to use a file system.

13
00:01:03,750 --> 00:01:08,880
So basically this file system model makes file operation API simple.

14
00:01:08,880 --> 00:01:14,970
We don't need to care about the directory and have the file is uploading in the S3.

15
00:01:14,970 --> 00:01:20,370
So basically we will use file system to get the file system, operation reading file and so on.

16
00:01:20,370 --> 00:01:26,760
Since we have created index each HTML file, we will read these index HTML file using the file system

17
00:01:26,760 --> 00:01:27,630
NPM package.

18
00:01:27,660 --> 00:01:33,950
In order to do that, please copy this npm install command for the file system and open the our.

19
00:01:33,960 --> 00:01:40,200
We just do code and come here and write the npm install file system hit enter.

20
00:01:40,200 --> 00:01:44,670
So this will be installed required file system package that we can see in all modules.

21
00:01:44,670 --> 00:01:46,860
And also you can see the package JSON file.

22
00:01:46,860 --> 00:01:52,200
So in the package JSON file, you can see the dependencies of the file system added successfully.

23
00:01:52,200 --> 00:01:55,470
So that means we will use file system after that.

24
00:01:55,470 --> 00:02:02,730
Now we can ready to implement our upload object JS file and if you open this file, I'm going to implement

25
00:02:03,000 --> 00:02:07,020
this file for you before and I will explain one by one.

26
00:02:07,110 --> 00:02:12,870
As you can see that we have a run method and in the run method we use a select client and the object

27
00:02:12,870 --> 00:02:17,970
command, which is the put object command for uploading a file and passing these parameters.

28
00:02:17,970 --> 00:02:19,650
All this path is the same.

29
00:02:19,650 --> 00:02:24,510
Only the change part is the using the different command, which is the put object command.

30
00:02:24,540 --> 00:02:27,240
If you go to parameters, you can see the parameters in here.

31
00:02:27,240 --> 00:02:29,400
These are the mandatory parameters.

32
00:02:29,400 --> 00:02:36,600
When we are uploading an object which is the bucket name key and the body bucket, we will import an

33
00:02:36,600 --> 00:02:37,770
object in this bucket.

34
00:02:37,770 --> 00:02:45,600
And key is the name of this object or unique identifier of the key name and the body is the file itself.

35
00:02:45,600 --> 00:02:47,330
So how we can get these files extreme?

36
00:02:47,370 --> 00:02:54,150
Of course we are using the file system libraries to get to read the file stream which passing the file

37
00:02:54,150 --> 00:03:01,680
into the first create method and get the file stream and paste these bytes file stream into the body

38
00:03:01,680 --> 00:03:02,550
information.

39
00:03:02,550 --> 00:03:11,070
So this is how we can use index HTML and how we can upload these HTML file into our bucket using the

40
00:03:11,070 --> 00:03:12,120
put object command.

41
00:03:12,120 --> 00:03:16,350
So after writing these codes, please come back to our.

42
00:03:17,280 --> 00:03:23,580
Terminal and run the node command node upload object command.

43
00:03:23,610 --> 00:03:29,120
Before that, you can make sure that you don't have any item into our S3 bucket.

44
00:03:29,130 --> 00:03:32,480
If you open the S3 bucket, you can see that we have no an object.

45
00:03:32,490 --> 00:03:40,770
So now I'm going to run this node command and as you can see that we got successfully upload our object

46
00:03:40,770 --> 00:03:44,730
in order to check these objects into our management console.

47
00:03:44,760 --> 00:03:51,090
We can click the refresh button and see that we have successfully upload index.html into our newly created

48
00:03:51,090 --> 00:03:51,750
bucket.

49
00:03:51,750 --> 00:03:56,640
So in the next video we are going to delete our Amazon S3 bucket using the SDK packages.
