Create folder inside a bucket in minio using JAVA SDK
Asked Answered
S

3

7

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!

Sycee answered 5/11, 2017 at 12:41 Comment(0)
N
10

In the objectName parameter prefix of the putObject method, you can specify a folder name. https://docs.minio.io/docs/java-client-api-reference#putObject https://github.com/minio/minio/issues/2423#issuecomment-239408168

For example:

//objectName = folderName + "/" + fileName;
minioClient.putObject(bucketName, objectName, inputStream, contentType);
Nilsanilsen answered 9/11, 2017 at 8:57 Comment(0)
S
1

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);

Seagrave answered 26/3, 2019 at 11:49 Comment(0)
C
1

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());
Cartierbresson answered 30/5, 2022 at 10:22 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Jarmon

© 2022 - 2024 — McMap. All rights reserved.