AWS S3 Presigned URL
1. Listing all buckets
- aws s3 ls
2. Creating a bucket in AWS CLI
- aws s3api create-bucket --bucket jongwoo-presigned-test-bucket
- It is also possible to set the region of our choice but it is not necessary since the bucket is in global region.
3. Uploading a file to the bucket
- aws s3api put-object --bucket jongwoo-presigned-test-bucket --key test-presigned.txt --body /home/jongwoo/text.txt
- '--bucket' specifies the name of the bucket.
- '--key' specifies the name to save. This is the name which will be appeared in the bucket.
- '--body' specifies the location of the file you want to upload.
4. Creating a presigned url from a file
- aws s3 presign s3://jongwoo-presigned-test-bucket/test-presigned.txt --expires-in 10
- '--expires-in <seconds>' specifies the duration of time in seconds of validity.
5. Testing the validity of presigned url
- curl 'https://jongwoo-presigned-test-bucket.s3.amazonaws.com/test-presigned.txt?AWSAccessKeyId=AKIA4IZ7JCWZMBQB5MOM&Signature=NWyJ3PMJGpeped7cYxPF9gKw060%3D&Expires=1641938906'
- curl '<presigned url'>
- It is also possible to test by directly copying and pasting the url to the chrome. It will download the file if it is valid in duration.