สำหรับใครที่ใช้งาน Digital Ocean Space แล้วต้องใช้คำสั่งในการจัดการแทนทำผ่านหน้าเว็บ เราสามารถใช้ aws cli จัดการได้แทน สะดวกมากๆ ทำได้เลยดังนี้
1. ติดตั้ง aws cli
วิธีติดตั้งอ่านได้จาก
Install or update the latest version of the AWS CLI - AWS Command Line Interface
Install the AWS CLI on your system.
2. สร้าง Spaces access keys
ไปที่ Digital Ocean > API > Spaces keys แล้วก็สร้าง Access Key กับ Secret key เก็บไว้ก่อน

3. สร้าง aws profile
ทำการใช้ aws cli ที่ติดตั้งไว้ข้อ 1. สร้าง config ไฟล์สำหรับ Digital Ocean Space
$ aws configure --profile doระบุ Secret key และ Access key ที่ได้มา ส่วนข้ออื่นเว้นว่างไว้

4. ลองใช้งาน
แสดง Bucket มาดู
$ aws s3 ls --profile do --endpoint=https://sgp1.digitaloceanspaces.comดาวโหลดไฟล์จาก DO space มายังเครื่องเรา
$ aws s3 cp --recursive --profile do --endpoint=https://sgp1.digitaloceanspaces.com s3://bucket_name/ ./Copy ไฟล์ระหว่าง Bucket และกำหนด --acl ไฟล์ให้
$ aws s3 --profile do cp --recursive --acl public-read --endpoint=https://sgp1.digitaloceanspaces.com s3://bucker_name/dev/ s3://bucker_name/prod/💡
endpoint ให้เปลี่ยนตาม space ที่เราสร้าง
AWS Command ศึกษาเพิ่มเติมได้จาก https://docs.aws.amazon.com/cli/latest/reference/s3/

Member discussion