استخدام واجهة محرر الأوامر الخاصة بـ AWS (CLI) مع خدمة تخزين الأغراض MEGA S4 يتيح لك دمج قوة سير العمل الآلي القابل للبرمجة مع موثوقية وأداء تخزين الأغراض المتوافقة مع S3 من ميغا MEGA. توفر AWS CLI مجموعة أدوات مألوفة ومرنة لإدارة الدلاء والأغراض على نطاق واسع، بينما توفر خدمة تخزين الأغراض MEGA S4 تخزيناً آمناً بتوافر عالي مع توافق بسيط مع واجهة برمجة تطبيقات S3. معاً، يجعل ذلك من السهل دمج خدمة تخزين الأغراض MEGA S4 في الأدوات والبنية التحتية الموجودة لديك.
The following steps will guide you through configuring the AWS CLI so you can start managing your MEGA S4 data from the command line.
قم بإعداد MEGA S4 الخاص بك
إنشاء دلو جديد
- انقر على تخزين الأغراض على اللوحة اليسرى.
- انقر علىإنشاء دلو.
- قم بتسمية الدلو.
- انقر إنشاء.
قم بإعداد مفاتيح الوصول الخاصة بك
- انقر على تخزين الأغراض على اللوحة اليسرى.
- انقر على المفاتيح على اللوحة اليسرى.
- انقر على إنشاء مفتاح.
- قم بتسمية المفتاح.
- انسخ مفتاح الوصول و المفتاح السري.
Set up AWS CLI
- Download and install AWS CLI from the Amazon website.
- Open a terminal in macOS or Linux, or command prompt in Windows.
- Run
aws configureand enter your the following information when prompted: - AWS Access Key ID: Enter the Access key you copied above.
- AWS Secret Access Key: Enter the Secret key you copied above.
- Default region name: Leave this blank.
- Default output format: Leave this blank.
To test that your AWS CLI is configured correctly
Enter the following command:aws s3 ls --endpoint-url=https://s3.eu-amsterdam.megas4.com
From now on you can run s3, s3api and iam commands.
Note that it is necessary to add the --endpoint-url subcommand after every command, e.g. https://s3.eu-amsterdam.megas4.com. For a list of all the endpoints, see the MEGA S4 settings.
Example commands
Create a presigned URL
Use the following template for the command:
aws s3 presign s3://your-bucket-name/path/to/your-object --endpoint-url https://your-endpoint-url/
- Replace the placeholders with your actual details:
- Bucket and object: Replace
s3://your-bucket-name/path/to/your-objectwith the path to your file - Example:
s3://test/images/Done.png - Endpoint URL: Use
--endpoint-urlto specify your S4 endpoint - Example:
https://s3.eu-amsterdam.megas4.com/
- Full example:
aws s3 presign s3://test/images/Done.png --endpoint-url https://s3.eu-amsterdam.megas4.com/
- Press Enter to execute the command.
- You should see a presigned URL output, like this:
https://s3.eu-amsterdam.megas4.com/test/images/Done.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAINZUQVEXKQ3E5RVXZCNCE5B4MUWOVIOTAPKMFRH4%2F20241107%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241107T013010Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=d5a9bef624017c64b57a8a91964249f2e13cd7296bffb7dfb33eba77c7b10c75
Set the time limit for your presigned URL
aws s3 presign s3://test/done.png --endpoint-url https://s3.eu-amsterdam.megas4.com/ --expires-in 604800
Examples are below – note the default is one hour.
--expires-in 604800 The presigned URL will expire in 7 days (the max time)
--expires-in 3600 The presigned URL will expire in 1 hour (the default)
To enable logs
When executing a command add the --debug parameter.
More examples
aws s3 ls --endpoint-url=https://s3.eu-amsterdam.megas4.com
aws s3api list-buckets --endpoint-url=https://s3.eu-amsterdam.megas4.com/
aws iam list-policies --endpoint-url=http://iam.eu-amsterdam.megas4.com/
For a list of all example commands, check the AWS CLI documentation.