البرمجة

تنزيل ملفات من دلو S3 باستخدام AWS CLI

To copy multiple files from an AWS S3 bucket to your local machine using the AWS CLI, you can use a loop to iterate over the list of filenames and copy each file individually. Here’s a general approach you can follow:

  1. Create a text file containing the list of filenames you want to download, with each filename on a new line. Let’s say the file is named filenames.txt.

  2. Use a shell script to read the file line by line and copy each file using the AWS CLI. Here’s an example script (assuming you’re using bash):

    bash
    #!/bin/bash # Read the filenames from the file while IFS= read -r filename; do # Copy the file from S3 to local machine aws s3 cp s3://your-bucket-name/$filename /path/to/local/directory/ done < filenames.txt

    Replace your-bucket-name with the name of your S3 bucket and /path/to/local/directory/ with the path to the directory where you want to save the files locally.

  3. Make the script executable and run it:

    bash
    chmod +x script.sh ./script.sh

This script will read each filename from filenames.txt, construct the S3 URL, and use the aws s3 cp command to copy the file to your local machine.

Make sure you have the AWS CLI installed and configured with the necessary credentials. You can install the AWS CLI and configure it by following the instructions in the AWS documentation.

المزيد من المعلومات

لتحميل عدة ملفات من دلو S3 باستخدام AWS CLI، يمكنك استخدام الأمر aws s3 cp داخل حلقة تكرار لنسخ كل ملف على حدة. هنا الخطوات التفصيلية:

  1. أنشئ ملف نصي يحتوي على قائمة بأسماء الملفات التي تريد تحميلها، مع كل اسم ملف في سطر جديد. لنفترض أن اسم الملف هو filenames.txt.

  2. استخدم سكربت شل لقراءة الملف سطرًا بسطر ونسخ كل ملف باستخدام AWS CLI. إليك سكربت مثالي (نفترض استخدامك للباش):

    bash
    #!/bin/bash # اقرأ أسماء الملفات من الملف while IFS= read -r filename; do # نسخ الملف من S3 إلى الجهاز المحلي aws s3 cp s3://اسم-دلوك/$filename /المسار/المحلي/للمجلد/ done < filenames.txt

    قم بتغيير اسم-دلوك باسم دلو S3 الخاص بك و/المسار/المحلي/للمجلد/ بالمسار إلى المجلد الذي تريد حفظ الملفات فيه محليًا.

  3. اجعل السكربت قابلاً للتنفيذ وقم بتشغيله:

    bash
    chmod +x script.sh ./script.sh

هذا السكربت سيقوم بقراءة كل اسم ملف من filenames.txt، وبناء عنوان URL لـ S3، واستخدام الأمر aws s3 cp لنسخ الملف إلى الجهاز المحلي.

تأكد من تثبيت AWS CLI وتكوينه بالاعتمادات اللازمة. يمكنك تثبيت AWS CLI وتكوينه من خلال اتباع التعليمات في توثيق AWS.

مقالات ذات صلة

زر الذهاب إلى الأعلى
إغلاق

أنت تستخدم إضافة Adblock

يرجى تعطيل مانع الإعلانات حيث أن موقعنا غير مزعج ولا بأس من عرض الأعلانات لك فهي تعتبر كمصدر دخل لنا و دعم مقدم منك لنا لنستمر في تقديم المحتوى المناسب و المفيد لك فلا تبخل بدعمنا عزيزي الزائر