I am using Java API (https://docs.min.io/docs/java-client-api-reference.html) to use Minio Client.
I want to create a new folder and a new file (empty or sample text) in existing bucket. How do I do it? Please note that I do not want to upload any existing file from local.
I am aware of below command:
minioClient.putObject(bucketName,objectName, "/path/to/file/object.txt");
But unlike above, I do not have "/path/to/file/object.txt" i.e. I want to create the new file directly in minio.
I saw some example in Python SDK:
client.put_object(
"my-bucket", "my-object", io.BytesIO(b"hello"), 5,
)
I would be fine with above but I need it in Java API? What does putObject (in Java) expects for above example?
If you want to create an empty directory with minio and java you can do as below:
minioClient.putObject(
PutObjectArgs.builder()
.bucket(bucketName)
.object("dir1/dir2/dir3/")
.stream(new ByteArrayInputStream(new byte[]{}), 0, -1)
.build());
which creates an empty dir3, and be aware to end your given path with "/".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With