Create folder inside a bucket in minio using JAVA SDK

Viewed 11983

The Minio JAVA SDK documentation doesn't clearly articulate how to create a folder inside a bucket.

Can somebody help me on this request ?

Thanks in Advance!

3 Answers

Create the bucket if its not present. To add folder within it add it to the name of file. Eg. File name: "sample.txt", Bucket Name: "main", SubFolder: "resrc" filePath: file which you want to upload

minioClient.putObject("main", "resrc" + "/" + "sample.txt", filePath);

Create or check for exist.

// Create object ends with '/' (also called as folder or directory).
minioClient.putObject(
PutObjectArgs.builder().bucket("my-bucketname").object("path/to/").stream(
new ByteArrayInputStream(new byte[] {}), 0, -1).build());
Related