-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a51f8e2
commit fecd1f9
Showing
4 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Minio Java Library for Amazon S3 Compatible Cloud Storage, (C) 2015 Minio, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import java.io.IOException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.InvalidKeyException; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import io.minio.MinioClient; | ||
import io.minio.BucketPolicy; | ||
import io.minio.errors.MinioException; | ||
|
||
public class GetBucketPolicy { | ||
public static void main(String[] args) | ||
throws IOException, NoSuchAlgorithmException, InvalidKeyException, XmlPullParserException { | ||
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are | ||
// dummy values, please replace them with original values. | ||
// For Amazon S3 endpoint, region is calculated automatically | ||
try { | ||
MinioClient minioClient = new MinioClient("https://play.minio.io:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY"); | ||
|
||
BucketPolicy policy = minioClient.getBucketPolicy("my-bucketname", "downloads"); | ||
System.out.println("Current policy: " + policy.toString()); | ||
} catch (MinioException e) { | ||
System.out.println("Error occured: " + e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Minio Java Library for Amazon S3 Compatible Cloud Storage, (C) 2015 Minio, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import java.io.IOException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.InvalidKeyException; | ||
|
||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import io.minio.MinioClient; | ||
import io.minio.BucketPolicy; | ||
import io.minio.errors.MinioException; | ||
|
||
public class SetBucketPolicy { | ||
public static void main(String[] args) | ||
throws IOException, NoSuchAlgorithmException, InvalidKeyException, XmlPullParserException { | ||
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are | ||
// dummy values, please replace them with original values. | ||
// For Amazon S3 endpoint, region is calculated automatically | ||
try { | ||
MinioClient minioClient = new MinioClient("https://play.minio.io:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY"); | ||
|
||
minioClient.setBucketPolicy("my-bucketname", "downloads", BucketPolicy.ReadOnly); | ||
} catch (MinioException e) { | ||
System.out.println("Error occured: " + e); | ||
} | ||
} | ||
} |