1 00:00:00,160 --> 00:00:01,110 So now we're talking about 2 00:00:01,110 --> 00:00:04,290 S3 pre-signed URLs, and so we've seen them before, 3 00:00:04,290 --> 00:00:06,050 but now we're going to do hands-on. 4 00:00:06,050 --> 00:00:08,050 So we can generate pre-signed URL 5 00:00:08,050 --> 00:00:10,710 using either the SDK or the CLI. 6 00:00:10,710 --> 00:00:12,630 And the easy thing to do is for downloads 7 00:00:12,630 --> 00:00:14,890 you can just use a CLI, but for uploads, 8 00:00:14,890 --> 00:00:17,800 it's a bit harder and you must use the SDK to use them. 9 00:00:17,800 --> 00:00:19,010 Nonetheless, it's quite easy 10 00:00:19,010 --> 00:00:21,310 and we'll do downloads in this lecture. 11 00:00:21,310 --> 00:00:23,100 Now, when you generate a pre-signed URL, 12 00:00:23,100 --> 00:00:26,250 by default it will have an expiration of 3,600 seconds, 13 00:00:26,250 --> 00:00:27,730 which is one hour. 14 00:00:27,730 --> 00:00:28,880 And you can change that timeout 15 00:00:28,880 --> 00:00:31,790 using an expires-in parameter, argument, 16 00:00:31,790 --> 00:00:33,770 and you specify the time in seconds. 17 00:00:33,770 --> 00:00:35,640 And when the user you give it, 18 00:00:35,640 --> 00:00:37,840 you give him a pre-signed URL. 19 00:00:37,840 --> 00:00:40,260 Basically they will inherit your permissions. 20 00:00:40,260 --> 00:00:43,190 So the one permission that created the object, 21 00:00:43,190 --> 00:00:45,960 so they can do, get, or put accordingly. 22 00:00:45,960 --> 00:00:46,900 So why would you do this? 23 00:00:46,900 --> 00:00:47,850 Well, there's many reasons, 24 00:00:47,850 --> 00:00:49,990 maybe you want to allow only logged-in users 25 00:00:49,990 --> 00:00:52,650 to download a premium video on your S3 bucket. 26 00:00:52,650 --> 00:00:55,830 So you only wanna give a downloading for maybe 15 minutes 27 00:00:55,830 --> 00:00:58,240 to a premium user that is logged in. 28 00:00:58,240 --> 00:01:01,300 Maybe you have an ever changing list of users 29 00:01:01,300 --> 00:01:03,050 that need to download files, and so, 30 00:01:03,050 --> 00:01:05,960 you don't wanna give them access directly to your bucket 31 00:01:05,960 --> 00:01:08,230 because it could be very dangerous or it's not maintainable 32 00:01:08,230 --> 00:01:10,540 because there's so many new users all the time. 33 00:01:10,540 --> 00:01:13,280 So maybe you want to generate URLs dynamically 34 00:01:13,280 --> 00:01:15,900 and give them the URLs over time, 35 00:01:15,900 --> 00:01:17,920 all by pre signing them all of them. 36 00:01:17,920 --> 00:01:20,990 And then maybe you want to allow temporarily a user 37 00:01:20,990 --> 00:01:23,880 to upload a file to a precise location in our buckets. 38 00:01:23,880 --> 00:01:26,150 For example, maybe you want to allow a user to upload 39 00:01:26,150 --> 00:01:28,830 a profile picture directly onto our S3 bucket. 40 00:01:28,830 --> 00:01:31,380 And so for this, we would generate a pre-signed URL, 41 00:01:31,380 --> 00:01:33,260 so there could be a lot of use cases. 42 00:01:33,260 --> 00:01:35,010 But let's go ahead and see how we can generate 43 00:01:35,010 --> 00:01:37,083 a pre-signed URL for a download.