publicstaticvoidmain(String[] args)throws IOException, NoSuchAlgorithmException, InvalidKeyException { try { // Create a minioClient with the MinIO server playground, its access key and secret key. MinioClientminioClient= MinioClient.builder() .endpoint("http://192.168.56.10:9000") .credentials("XO1JDovW2FTmGaBb", "uG6wMfylUnOVH5WzwxqnldOWw2dMshNX") .build();
// Make 'asiatrip' bucket if not exist. booleanfound= minioClient.bucketExists(BucketExistsArgs.builder().bucket("public").build()); if (!found) { // Make a new bucket called 'asiatrip'. minioClient.makeBucket(MakeBucketArgs.builder().bucket("public").build()); } else { System.out.println("Bucket 'public' already exists."); }
// Upload '/home/user/Photos/asiaphotos.zip' as object name 'asiaphotos-2015.zip' to bucket // 'asiatrip'. minioClient.uploadObject( UploadObjectArgs.builder() .bucket("public") .object("credentials.json") .filename("C:/Users/lai.huanxiong/Downloads/credentials.json") .build()); System.out.println("'C:/Users/lai.huanxiong/Downloads/credentials.json' is successfully uploaded as " + "object 'credentials.json' to bucket 'public'."); } catch (MinioException e) { System.out.println("Error occurred: " + e); System.out.println("HTTP trace: " + e.httpTrace()); } } }