0

Hi!

I have a problem communicating with MinIO using R in an optimal way. The task is to list the available folders in a given subfolder located in the appropriate bucket.

Example: A bucket named test_bucket contains n folders:

  • folder_1,
  • folder_2,
  • ...
  • folder_n

Each of them contains some subfolders, for example folder_1 contains:

  • sub_folder_1.1
  • sub_folder_1.2
  • ...
  • sub_folder_1.n

Similarly, the remaining folders.

How do I get a list of folders (without any subfolders!) from folder folder_2?

I managed to do it in a rather primitive way, i.e. first I downloaded the entire contents of the bucket using the minio.s3::get_bucket_df function and then filtered the paths accordingly and obtained the answer.

But this solution is ok, for buckets that do not contain much data, in a situation where it is very extensive with a lot of subfolders, it becomes very suboptimal, because we are unnecessarily searching through a huge area of ​​data.

Is there a way to scan only the indicated folder and return its main content, i.e. the names of files and folders (without their contents) located in it?

1 Answer 1

0

Assuming your bucket name is test_bucket and you want to list all the directories inside it without traversing their contents, the following mc command pattern can help:

mc ls [MINIO_ALIAS]/[BUCKET_NAME]

Let's break down the details:

  • mc: The MinIO Client that allows you to interact with MinIO via the command line interface (CLI).
  • ls: The list command, used for listing objects and directories.
  • [MINIO_ALIAS]: The alias of your running MinIO instance.
  • [BUCKET_NAME]: The name of the bucket you want to work with.

Following the above pattern your required command will be like:

mc ls minio/test_bucket

In any programming language, you can write equivalent code to execute this command. Just make sure to set the recursive property to False so that it doesn’t list the sub-directories.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.