Preloader
Skip to content
How to make all files in an S3 bucket public

How to make all files in an S3 bucket public

This article is published in Vietnamese.

How to make all files in an S3 bucket public

Bản chất việc thiết lập ACL Public cho 1 Bucket cho phép public danh sách các object có trong bucket đó, nên khi người dùng thực hiện truy cập vào một file thì không thể truy cập được và thông báo như sau

Public toàn bộ files trong một S3 bucket - Ảnh 1.

 

Mặc dù Bucket này đã public như thiết lập sau

Public toàn bộ files trong một S3 bucket - Ảnh 2.

 

Do vậy, để có thể truy cập vào file trong bucket trên ta có 2 cách:

- Thực hiện set public đối với toàn bộ file khi thực hiện upload

- Hoặc sử dụng bucket policy để thiết lập bucket.

Trong bài này, tôi sẽ sử dụng bucket policy để thiết lập public cho toàn bộ file trong bucket.

Để thực hiện điều này, ta sử dụng lệnh s3cmd. Xem thêm hướng dẫn cấu hình s3cmd tại [1].

Tạo file `policy.json` như sau

{ "Version":"2012-10-17", "Statement":[{ "Sid":"AddPerm", "Effect":"Allow", "Principal": "*", "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::sapd-test-bucket-private/*" ] } ] }

Với sapd-test-bucket-private đây là tên bucket của bạn, bạn cần thay thế tương ứng với bucket mà bạn muốn public toàn bộ file trong bucket đó.

Thiết lập policy cho bucket bằng lệnh sau

s3cmd setpolicy policy.json s3://sapd-test-bucket-private

Kiểm tra lại thông tin policy

sapd@sapd ~/WORK/VC/s3 $ s3cmd info s3://sapd-test-bucket-private s3://sapd-test-bucket-private/ (bucket): Location: hn Payer: BucketOwner Expiration Rule: none Policy: b'{\n "Version":"2012-10-17",\n "Statement":[{\n "Sid":"AddPerm",\n "Effect":"Allow",\n "Principal": "*",\n "Action":["s3:GetObject"],\n "Resource":["arn:aws:s3:::sapd-test-bucket-private/*"\n ]\n }\n ]\n}\n' CORS: none ACL: *anon*: READ ACL: sapd@vccloud.vn: FULL_CONTROL URL: http://sapd-test-bucket-private.ss-hn-1.vccloud.vn/

Thực hiện truy cập vào file trong bucket.

Tada

Public toàn bộ files trong một S3 bucket - Ảnh 6.
Share:
Trương Công Thành
Author

Trương Công Thành

Pho Tue SoftWare Solutions JSC là Nhà Cung cấp dịch Trung Tâm Dữ Liệu, Điện Toán Đám Mây Và Phát Triển Phần Mềm Hàng Đầu Việt Nam. Hệ Thống Data Center Đáp Ứng Mọi Nhu Cầu Với Kết Nối Internet Nhanh, Băng Thông Lớn, Uptime Lên Đến 99,99% Theo Tiêu Chuẩn TIER III-TIA 942.

Leave a comment

Your email address will not be published. Required fields are marked *

Trusted by more than 85,000 customers in Vietnam and worldwide

Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo
Customer logo

Technology partners we build with

Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo
Partner logo

Resources for building your digital infrastructure

Technical support

Start your deployment with a dedicated Pho Tue Software team.

Latest updates

Service announcements, in-depth analysis and ecosystem activity.

International certifications and security standards

Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard
Certification and standard

Member of regional and national internet registries

Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
Internet registry
We use cookies to improve your experience on this website. Privacy policy