From 58f934125136bcb109290ee37c52263ac037cba4 Mon Sep 17 00:00:00 2001 From: Maciej Wielgosz <maciej.wielgosz@nibio.no> Date: Wed, 26 Jul 2023 12:13:36 +0200 Subject: [PATCH] transfer folder with files to the oracle bucket --- oracle_scripts/send_folder_to_bucket.sh | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 oracle_scripts/send_folder_to_bucket.sh diff --git a/oracle_scripts/send_folder_to_bucket.sh b/oracle_scripts/send_folder_to_bucket.sh new file mode 100644 index 0000000..44c370a --- /dev/null +++ b/oracle_scripts/send_folder_to_bucket.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Check if both arguments are provided +if [ "$#" -ne 2 ]; then + echo "Usage: $0 source_directory bucket_name" + exit 1 +fi + +# Source directory and bucket name parameters +SRC_DIR=$1 +BUCKET_NAME=$2 + +# Function for uploading files +upload_files() { + local src_path=$1 + local dest_path=$2 + + # Iterate over the files and directories + for item in "$src_path"/*; do + # If it's a directory, recursively call this function + if [ -d "$item" ]; then + upload_files "$item" "$dest_path/$(basename "$item")" + else + # If it's a file, upload it to the OCI bucket + oci os object put --bucket-name "$BUCKET_NAME" --name "$dest_path/$(basename "$item")" --file "$item" + fi + done +} + +# Invoke the function with root directory +upload_files "$SRC_DIR" "$(basename "$SRC_DIR")" + +# sample usage +# bash oracle_scripts/send_folder_to_bucket.sh data/simple/ e2e_seg_data \ No newline at end of file -- GitLab