針對大量作業使用 Oracle Cloud Infrastructure Object Storage Python 公用程式
簡介
Oracle Cloud Infrastructure (OCI) Object Storage 可讓客戶以其原生格式安全地儲存任何類型的資料。透過內建備援功能,OCI Object Storage 適合用於建置需要擴展和彈性的現代化應用程式,因為它可以用來合併多個資料來源以進行分析、備份或封存。
OCI Object Storage 是雲端工作負載的基礎,具有彈性、可擴展性、可靠性及成本效益,使其成為雲端非結構化資料的主要儲存空間。由於廣受歡迎的緣故,使用 OCI Object Storage 有大量的工具生態系統。本教程是「動力工具」系列中的第一個,旨在為用戶提供更熟悉各種可用工具和如何在工作負載中使用這些工具的途徑。
本教學課程介紹使用 Python SDK 搭配 OCI Object Storage 進行大量作業的 GitHub 中提供的範例命令檔。
適用對象
DevOps 工程師、開發人員、OCI 物件儲存管理員和使用者、IT 管理者、OCI 超級使用者和應用程式管理員。
目標
- 使用 Python 命令檔範例處理 OCI 物件儲存中的大量作業,例如大量回復、刪除、複製、重新命名以及列出物件資訊。
必備條件
-
OCI 帳戶。
-
您本位目錄中名為
.oci之子目錄的工作組態檔。如需更多資訊,請參閱設定配置檔案。 -
存取 OCI Object Storage 貯體。
-
OCI 中使用 OCI Object Storage 的使用者權限,可存取至少 1 個儲存桶中的物件。如需詳細資訊,請參閱一般原則和原則參照。
-
執行環境:存取 OCI Cloud Shell (Linux OCI 執行處理 )。
-
Git 套裝軟體安裝於執行環境中並熟悉
git指令。 -
已安裝 Python 3。
-
熟悉 Python 和 Python 模組。
作業 1:設定環境
-
安裝 OCI 軟體開發套件 (SDK) 套件。
pip3 install --user oci -
複製 OCI SDK 儲存區域。
$ git clone https://github.com/oracle/oci-python-sdk Cloning into 'oci-python-sdk'... remote: Enumerating objects: 113452, done. remote: Counting objects: 100% (23584/23584), done. remote: Compressing objects: 100% (3022/3022), done. remote: Total 113452 (delta 20706), reused 23195 (delta 20521), pack-reused 89868 Receiving objects: 100% (113452/113452), 77.07 MiB | 12.78 MiB/s, done. Resolving deltas: 100% (104373/104373), done.注意:這些是使用 OCI Python SDK 的範例命令檔,它們不是正式的 Oracle 應用程式,且不受 Oracle 維護或支援。這些都是範例,因此您可能會想要在自己的軟體儲存區域中複查、更新及自訂使用案例。
-
切換至範例目錄。如果安裝在您的主目錄中,請執行下列指令。
cd $HOME/oci-python-sdk/examples/object_storage
工作 2:使用物件大量還原指令碼
大量回復命令檔會以平行繫線回復來源儲存桶中存檔的物件。
-
執行不含引數的大量回復命令檔,以查看必要的引數。
$ python object_storage_bulk_restore.py Source bucket parameter is required !!! usage: object_storage_bulk_restore.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-ip] [-dt] [-c CONFIG_FILE] [-sb SOURCE_BUCKET] [-sp SOURCE_PREFIX_INCLUDE] [-sr SOURCE_REGION] [-sn SOURCE_NAMESPACE] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -c CONFIG_FILE Config File (default=~/.oci/config) -sb SOURCE_BUCKET Source Bucket Name -sp SOURCE_PREFIX_INCLUDE Source Prefix Include -sr SOURCE_REGION Source Region -sn SOURCE_NAMESPACE Source Namespace (Default current connection)注意:此教學課程將使用所有命令檔的組態檔。若未將命令檔指定為命令檔引數,命令檔將預設為組態檔中所列的區域。
-
不使用前置碼引數執行命令檔。這將會回復所有存檔物件。
$ python object_storage_bulk_restore.py -c $HOME/.oci/config -sb MyBucket Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Restore # ########################################################################################## Written by Tim S and Adi Z, July 2020 Starts at : 2024-05-30 16:44:18 Command Line : -c /home/opc/.oci/config -sb MyBucket Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : ########################################################################################## # Start Processing # ########################################################################################## 16:44:18 - Creating 40 workers. 16:44:18 - Getting list of objects from source source_bucket (MyBucket). Restores will start immediately. 16:44:19 - Enqueued 9086 objects to be restored 16:44:19 - Waiting 60 seconds before checking status. 16:45:19 - Restoration of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 16:45:19注意:回復的物件無法立即使用。從提出存檔儲存回復要求到擷取第一個位元組資料的時間,還原最多需要一個小時。
-
使用前置碼引數執行命令檔。
$ python object_storage_bulk_restore.py -c $HOME/.oci/config -sb MyBucket -sp folder1 Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Restore # ########################################################################################## Written by Tim S and Adi Z, July 2020 Starts at : 2024-05-30 17:00:09 Command Line : -c /home/opc/.oci/config -sb MyBucket -sp folder1 Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : folder1 ########################################################################################## # Start Processing # ########################################################################################## 17:00:09 - Creating 40 workers. 17:00:09 - Getting list of objects from source source_bucket (MyBucket). Restores will start immediately. 17:00:10 - Enqueued 1096 objects to be restored 17:00:10 - Waiting 60 seconds before checking status. 17:01:10 - Restoration of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 17:01:10注意:將會回復具名前置碼 / 資料夾和子前置碼 / 子資料夾中的所有已存檔物件。
作業 3:使用物件大量刪除腳本
物件大量刪除命令檔會刪除儲存桶中含有篩選選項的物件。
-
不使用引數執行命令檔以查看用法。
$ python object_storage_bulk_delete.py Source bucket parameter is required !!! usage: object_storage_bulk_delete.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-ip] [-dt] [-c CONFIG_FILE] [-sb SOURCE_BUCKET] [-sp SOURCE_PREFIX] [-se SOURCE_PREFIX_EXCLUDE] [-exclude_dirs] [-sn SOURCE_NAMESPACE] [-sr SOURCE_REGION] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -c CONFIG_FILE Config File (default=~/.oci/config) -sb SOURCE_BUCKET Source Bucket Name -sp SOURCE_PREFIX Source Prefix Include -se SOURCE_PREFIX_EXCLUDE Source Prefix Exclude -exclude_dirs Exclude Directories -sn SOURCE_NAMESPACE Source Namespace (Default current connection) -sr SOURCE_REGION Source Region備註:執行不含包含或排除首碼的指令碼將會刪除分組中的所有項目。
-
執行大量刪除命令檔並設定包括前置碼、複查輸出,以及回應
y/N提示。注意:執行命令時,將會刪除前置碼 / 資料夾和子前置碼 / 子資料夾中的所有物件。如果找不到相符項目,則會刪除分組中的所有項目。
$ python object_storage_bulk_delete.py -c $HOME/.oci/config -sb MyBucket -sp folder1 Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Delete # ########################################################################################## Written by Adi Zohar, July 2020 Starts at : 2024-05-30 18:51:32 Command Line : -c /home/opc/.oci/config -sb MyBucket -sp folder1 Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : folder1 Source Prefix Exclude : Source Region : us-ashburn-1 Are you sure you want to continue deleting ? [y/N]: y ########################################################################################## # Start Processing # ########################################################################################## 18:51:38 - Creating 40 workers. 18:51:38 - Getting list of objects from source source_bucket (MyBucket). delete will start immediately. 18:51:38 - Enqueued 700 objects to be deleted 18:51:38 - Waiting 60 seconds before checking status. 18:52:38 - deletion of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 18:52:38 -
執行包含排除字首的大量刪除指令碼。
$ python object_storage_bulk_delete.py -c $HOME/.oci/config -sb MyBucket -se folder1 Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Delete # ########################################################################################## Written by Adi Zohar, July 2020 Starts at : 2024-05-30 19:02:53 Command Line : -c /home/opc/.oci/config -sb MyBucket -se folder1 Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : Source Prefix Exclude : folder1 Source Region : us-ashburn-1 Are you sure you want to continue deleting ? [y/N]: y ########################################################################################## # Start Processing # ########################################################################################## 19:02:58 - Creating 40 workers. 19:02:58 - Getting list of objects from source source_bucket (MyBucket). delete will start immediately. 19:02:58 - Enqueued 60 objects to be deleted 19:02:58 - Waiting 60 seconds before checking status. 19:03:58 - deletion of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 19:03:58注意:儲存桶中不在排除前置碼 / 資料夾中的所有物件都將被刪除。執行此命令檔時請小心。如果找不到相符項目,將會刪除儲存桶中的所有物件。
作業 4:使用物件大量重新命名命令檔
大量重新命名命令檔可用來重新命名物件,或將物件移至其他資料夾 / 前置碼。請務必瞭解重新命名命令檔只會變更物件的名稱描述資料,這不是物件的複本,這只是重新命名。
-
執行不含引數的物件大量重新命名命令檔,以查看必要的參數。
$ python object_storage_bulk_rename.py Source bucket parameter is required !!! usage: object_storage_bulk_rename.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-ip] [-dt] [-c CONFIG_FILE] [-sb SOURCE_BUCKET] [-sp SOURCE_PREFIX_INCLUDE] [-sr SOURCE_REGION] [-sn SOURCE_NAMESPACE] [-textrem TEXT_REMOVE] [-textadd TEXT_APPEND] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -c CONFIG_FILE Config File (default=~/.oci/config) -sb SOURCE_BUCKET Source Bucket Name -sp SOURCE_PREFIX_INCLUDE Source Prefix Include -sr SOURCE_REGION Source Region -sn SOURCE_NAMESPACE Source Namespace (Default current connection) -textrem TEXT_REMOVE text remove prefix (can be used to remove folder) -textadd TEXT_APPEND text append prefix (can be used to add folder) -
執行作業系統物件清單以顯示儲存桶中目前的物件。
現有物件:
$ oci os object list --bucket-name MyBucket --query "data[].name" [ "file_1.txt", "file_10.txt", "file_2.txt", "file_3.txt", "file_4.txt", "file_5.txt", "file_6.txt", "file_7.txt", "file_8.txt", "file_9.txt", "hello_world" ] -
開始時執行物件大量重新命名命令檔,使用 file 變更物件的名稱,然後將它取代為 object 。
$ python object_storage_bulk_rename.py -c $HOME/.oci/config -sb MyBucket -textrem file -textadd object Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Rename # ########################################################################################## Written by Adi Z, March 2021 Starts at : 2024-05-31 23:09:13 Command Line : -c /home/opc/.oci/config -sb MyBucket -textrem file -textadd object Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : file Text Remove Prefix : file Text Append Prefix : object ########################################################################################## # Start Processing # ########################################################################################## 23:09:13 - Creating 40 workers. 23:09:13 - Getting list of objects from source source_bucket (MyBucket). Rename will start immediately. 23:09:13 - Enqueued 10 objects to be Renamed 23:09:13 - Waiting 60 seconds before checking status. 23:10:13 - Rename of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-31 23:10:13 -
執行作業系統物件清單以顯示儲存桶中目前的物件,並注意名稱變更。
$ oci os object list --bucket-name MyBucket --query "data[].name" [ "hello_world", "object_1.txt", "object_10.txt", "object_2.txt", "object_3.txt", "object_4.txt", "object_5.txt", "object_6.txt", "object_7.txt", "object_8.txt", "object_9.txt" ] -
將名稱中包含字串
object的所有物件移到名為dir1的目錄中。$ python object_storage_bulk_rename.py -c $HOME/.oci/config -sb MyBucket -sp object -textadd dir1/ Connecting to Object Storage Service... Succeed. ########################################################################################## # Running Object Storage Bulk Rename # ########################################################################################## Written by Adi Z, March 2021 Starts at : 2024-05-31 23:16:14 Command Line : -c /home/opc/.oci/config -sb MyBucket -sp object -textadd dir1/ Source Namespace : namespace Source Bucket : MyBucket Source Prefix Include : object Text Remove Prefix : Text Append Prefix : dir1/ ########################################################################################## # Start Processing # ########################################################################################## 23:16:14 - Creating 40 workers. 23:16:14 - Getting list of objects from source source_bucket (MyBucket). Rename will start immediately. 23:16:15 - Enqueued 10 objects to be Renamed 23:16:15 - Waiting 60 seconds before checking status. 23:17:15 - Rename of all objects has been requested. ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-31 23:17:15 -
執行作業系統物件清單,以再次顯示儲存桶中目前的物件,並注意已移至
dir1資料夾 / 前置碼的物件。$ oci os object list --bucket-name MyBucket --query "data[].name" [ "dir1/object_1.txt", "dir1/object_10.txt", "dir1/object_2.txt", "dir1/object_3.txt", "dir1/object_4.txt", "dir1/object_5.txt", "dir1/object_6.txt", "dir1/object_7.txt", "dir1/object_8.txt", "dir1/object_9.txt", "hello_world" ]
工作 5:使用物件大量複製指令碼
大量複製命令檔會在儲存桶之間複製物件,供用於在不同區域或不同租用戶的儲存桶之間複製物件。本教學課程將示範相同租用戶中跨區域的儲存桶之間、us-ashburn-1 中的一個儲存桶,以及 us-phoenix-1 中另一個儲存桶之間的複本。如果您想要跨租用戶使用命令檔,請參閱跨租用戶存取物件儲存資源。
注意:您可以使用更強大的工具,在儲存桶之間大量複製物件,例如 Rclone 或 Obect Storage Replication 。
-
執行不含引數的物件大量複製指令碼,以瞭解所需的參數。
$ python object_storage_bulk_copy.py usage: object_storage_bulk_copy.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-ip] [-dt] [-c CONFIG_FILE] [-sb SOURCE_BUCKET] [-sr SOURCE_REGION] [-sn SOURCE_NAMESPACE] [-sp SOURCE_PREFIX_INCLUDE] [-se SOURCE_PREFIX_EXCLUDE] [-db DESTINATION_BUCKET] [-dr DESTINATION_REGION] [-dn DESTINATION_NAMESPACE] [-ig] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -c CONFIG_FILE Config File (default=~/.oci/config) -sb SOURCE_BUCKET Source Bucket Name -sr SOURCE_REGION Source Region (Default current connection) -sn SOURCE_NAMESPACE Source Namespace (Default current connection) -sp SOURCE_PREFIX_INCLUDE Source Prefix Include -se SOURCE_PREFIX_EXCLUDE Source Prefix Exclude -db DESTINATION_BUCKET Destination Bucket Name -dr DESTINATION_REGION Destination Region -dn DESTINATION_NAMESPACE Destination Namespace (Default current connection) -ig Ignore Check if files exist at Destination -
執行物件大量物件複製命令,將資料夾 / 前置碼中的物件複製到另一個區域的儲存桶。
注意:在此範例中,目的地儲存桶是空的。
$ python object_storage_bulk_copy.py -c $HOME/.oci/config -sb MySourceBucket -db MyDestBucket -dr us-phoenix-1 ########################################################################################## # Connecting to Object Storage # ########################################################################################## Connecting to Object Storage Service for source region - us-ashburn-1 Succeed. Connecting to Object Storage Service for destination region - us-phoenix-1 Succeed. ########################################################################################## # Running Object Storage Bulk Copy # ########################################################################################## Written by Tim S and Adi Z, July 2020 Starts at : 2024-05-31 19:38:52 Command Line : -c /home/opc/.oci/config -sb MySourceBucket -db MyDestBucket Source Namespace : namespace Source Region : us-ashburn-1 Source Bucket : MySourceBucket Source Prefix : Dest Namespace : namespace Dest Region : us-phoenix-1 Dest Bucket : MyDestBucket State File : MySourceBucket.bulk.wrk ########################################################################################## # Start Processing # ########################################################################################## 19:38:52 - Creating 50 copy request workers. 19:38:52 - Creating 50 status workers. 19:38:52 - Loading list of objects from destination bucket (MyDestBucket) to ignore exiting files. 19:38:52 - Loaded 0 files. 19:38:52 - Getting list of objects from source bucket (MySourceBucket). Copies will start immediately. 19:38:52 - Enqueued 5 objects to be copied [...snip...] ########################################################################################## # Finish queuing files, start checking # ########################################################################################## 19:38:52 - Waiting 60 seconds before checking status. 19:39:52 - Determining copy status 19:39:52 - KNOWN: 1, REQUESTED: 0, COMPLETED: 4, FAILED: 0, CANCELED: 0
工作 6:使用物件儲存清單資料夾命令檔
物件儲存清單資料夾命令檔會列出儲存桶中的每個資料夾 / 前置碼、每個資料夾中所有物件 (KB) 的大小總計,以及每個資料夾中的物件數目。您可以選擇以前置碼 / 資料夾進行篩選。
-
執行沒有引數的物件清單資料夾命令檔,以瞭解命令行選項。
$ python object_storage_list_folders.py Source bucket parameter is required !!! usage: object_storage_list_folders.py [-h] [-t CONFIG_PROFILE] [-p PROXY] [-ip] [-dt] [-c CONFIG_FILE] [-sb SOURCE_BUCKET] [-sp SOURCE_PREFIX] [-sr SOURCE_REGION] [-sn SOURCE_NAMESPACE] [-f FILE] optional arguments: -h, --help show this help message and exit -t CONFIG_PROFILE Config file section to use (tenancy profile) -p PROXY Set Proxy (i.e. www-proxy-server.com:80) -ip Use Instance Principals for Authentication -dt Use Delegation Token for Authentication -c CONFIG_FILE Config File (default=~/.oci/config) -sb SOURCE_BUCKET Source Bucket Name -sp SOURCE_PREFIX Source Prefix Include -sr SOURCE_REGION Source Region -sn SOURCE_NAMESPACE Source Namespace (Default current connection) -f FILE Output to file (as csv) -
對整個儲存桶執行物件清單資料夾命令檔。
$ python object_storage_list_folders.py -c $HOME/.oci/config -sb MyBucket Connecting to Object Storage Service... Success. ########################################################################################## # Running List/Count Objects # ########################################################################################## Written By Adi Zohar, June 2020 Starts at :2024-05-30 21:25:06 Command Line : -c /home/opc/.oci/config -sb MyBucket Source Namespace : namespace Source Bucket : MyBucket Source Prefix : ########################################################################################## # Start Processing... # ########################################################################################## Folder Name | Size (KB) | Count -------------------------------------------------------------------------------- dir_1/ | 10240000.00 | 10 dir_10/ | 10240000.00 | 10 dir_2/ | 10240000.00 | 10 dir_3/ | 10240000.00 | 10 dir_4/ | 10240000.00 | 10 dir_5/ | 10240000.00 | 10 dir_6/ | 10240000.00 | 10 dir_7/ | 10240000.00 | 10 dir_8/ | 10240000.00 | 10 dir_9/ | 10240000.00 | 10 ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 21:25:06 Total Files : 103 Total Size : 137,069,854,720 -
對特定資料夾 / 前置碼執行物件清單資料夾命令檔。
$ python object_storage_list_folders.py -c $HOME/.oci/config -sb MyBucket -sp dir_1/ Connecting to Object Storage Service... Success. ########################################################################################## # Running List/Count Objects # ########################################################################################## Written By Adi Zohar, June 2020 Starts at :2024-05-30 21:27:41 Command Line : -c /home/opc/.oci/config -sb MyBucket -sp dir_1/ Source Namespace : namespace Source Bucket : MyBucket Source Prefix : dir_1/ ########################################################################################## # Start Processing... # ########################################################################################## Folder Name | Size (KB) | Count -------------------------------------------------------------------------------- dir_1/ | 10240000.00 | 10 ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-30 21:27:42 Total Files : 10 Total Size : 10,485,760,000
工作 7:使用物件儲存清單物件命令檔
物件清單命令檔會列出儲存桶中的每個物件、每個物件的大小 (位元組)、所有物件的大小總計,以及所有物件的計數。您可以選擇以前置碼 / 資料夾進行篩選。物件清單指令碼也可用於根據字串在貯體或首碼中搜尋物件。
-
對整個儲存桶執行物件清單命令檔。
$ python object_storage_list_objects.py -c $HOME/.oci/config -sb MyBucket Connecting to Object Storage Service... Success. ########################################################################################## # Running List/Count Objects # ########################################################################################## Written By Adi Zohar, June 2020 Starts at :2024-05-31 18:25:16 Command Line : -c /home/opc/.oci/config -sb MyBucket Source Namespace : namespace Source Bucket : MyBucket Source Prefix : Source Pre-Exclude : ########################################################################################## # Start Processing... # ########################################################################################## 10,737,418,240 | C 2024-01-30 23:58 | U 2024-01-30 23:58 | Standard | 10GB-Testfile 10,737,418,240 | C 2024-01-25 19:41 | U 2024-01-25 19:41 | Standard | 10GB-file 10,737,418,240 | C 2024-01-24 22:13 | U 2024-01-24 22:13 | Standard | 10GB_file 1,048,576,000 | C 2024-01-24 22:13 | U 2024-01-24 22:13 | Standard | dir_1/file_1 1,048,576,000 | C 2024-01-24 22:14 | U 2024-01-24 22:14 | Standard | dir_1/file_10 [...snip...] 1,048,576,000 | C 2024-01-24 23:10 | U 2024-01-24 23:10 | Standard | dir_9/file_8 1,048,576,000 | C 2024-01-24 23:10 | U 2024-01-24 23:10 | Standard | dir_9/file_9 ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-31 18:25:16 Total Files : 103 Total Size : 137,069,854,720 -
執行清單物件命令檔,並依資料夾 / 前置碼進行篩選。
$ python object_storage_list_objects.py -c $HOME/.oci/config -sb MyBucket -sp dir_1/ Connecting to Object Storage Service... Success. ########################################################################################## # Running List/Count Objects # ########################################################################################## Written By Adi Zohar, June 2020 Starts at :2024-05-31 18:49:49 Command Line : -c /home/opc/.oci/config -sb MyBucket -sp dir_1/ Source Namespace : namespace Source Bucket : MyBucket Source Prefix : dir_1/ Source Pre-Exclude : ########################################################################################## # Start Processing... # ########################################################################################## 1,048,576,000 | C 2024-01-24 22:13 | U 2024-01-24 22:13 | Standard | dir_1/file_1 1,048,576,000 | C 2024-01-24 22:14 | U 2024-01-24 22:14 | Standard | dir_1/file_10 1,048,576,000 | C 2024-01-24 22:15 | U 2024-01-24 22:15 | Standard | dir_1/file_2 1,048,576,000 | C 2024-01-24 22:16 | U 2024-01-24 22:16 | Standard | dir_1/file_3 1,048,576,000 | C 2024-01-24 22:17 | U 2024-01-24 22:17 | Standard | dir_1/file_4 1,048,576,000 | C 2024-01-24 22:17 | U 2024-01-24 22:17 | Standard | dir_1/file_5 1,048,576,000 | C 2024-01-24 22:17 | U 2024-01-24 22:17 | Standard | dir_1/file_6 1,048,576,000 | C 2024-01-24 22:18 | U 2024-01-24 22:18 | Standard | dir_1/file_7 1,048,576,000 | C 2024-01-24 22:19 | U 2024-01-24 22:19 | Standard | dir_1/file_8 1,048,576,000 | C 2024-01-24 22:20 | U 2024-01-24 22:20 | Standard | dir_1/file_9 ########################################################################################## # Completed # ########################################################################################## Completed at : 2024-05-31 18:49:49 Total Files : 10 Total Size : 10,485,760,000 -
執行清單物件命令檔,並在前置碼 / 資料夾的物件開頭篩選字串的資料夾 / 前置碼。
$ python object_storage_list_objects.py -sb MyBucket -sp dir2/foo
Connecting to Object Storage Service...
Success.
##########################################################################################
# Running List/Count Objects #
##########################################################################################
Written By Adi Zohar, June 2020
Starts at :2025-09-19 23:09:47
Command Line : -sb ash-30M -sp dir2/foo
Source Namespace : ocitsammut
Source Bucket : MyBucket
Source Prefix : dir2/foo
Source Pre-Exclude :
##########################################################################################
# Start Processing... #
##########################################################################################
4 | C 2025-09-19 21:34 | U 2025-09-19 21:34 | Standard | dirr2/foo.txt
4 | C 2025-09-19 21:34 | U 2025-09-19 21:34 | Standard | dir2/foo1.txt
4 | C 2025-09-19 21:34 | U 2025-09-19 21:34 | Standard | dir2/foo2.txt
##########################################################################################
# Completed #
##########################################################################################
Completed at : 2025-09-19 23:09:47
Total Files : 3
Total Size : 12
相關連結
確認
-
作者 - Melinda Centeno (資深首席產品經理)
-
貢獻者 - Adi Zohar (首席雲端架構師)、Tim Sammut (技術人員諮詢成員)
其他學習資源
在 docs.oracle.com/learn 上探索其他實驗室,或在 Oracle Learning YouTube 頻道上存取更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Use Oracle Cloud Infrastructure Object Storage Python Utilities for Bulk Operations
G10219-03