-1

I would like to know if there is a way to upload all the files contained in a folder to minIO, or if there is a method already implemented.

To upload one file is very simple, but I can't find a way to upload several files that are inside a directory in local

Willy RL
  • 21
  • 2

1 Answers1

0

You can try this out

def upload_local_directory_to_minio(local_path: str, bucket_name: str):
    assert os.path.isdir(local_path)

    for local_file in glob.glob(local_path + '/**'):
        local_file = local_file.replace(os.sep, "/")
        if not os.path.isfile(local_file):
            upload_local_directory_to_minio(
                local_file, bucket_name)
        else:
            remote_path = os.path.join(
                local_file[1 + len(local_path):])
            remote_path = remote_path.replace(
                os.sep, "/")
            minioClient.fput_object(bucket_name, remote_path, local_file)