litiliu commented on code in PR #12620:
URL:
https://github.com/apache/dolphinscheduler/pull/12620#discussion_r1161488011
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/storage/impl/S3Utils.java:
##########
@@ -401,23 +400,24 @@ private void downloadDirectory(String tenantCode, String
keyPrefix, String srcPa
}
}
- public void checkBucketNameExists(String bucketName) {
- if (StringUtils.isBlank(bucketName)) {
- throw new IllegalArgumentException("resource.aws.s3.bucket.name is
blank");
+ /**
+ * check permission by list S3 Directory
+ *
+ * @param bucketName
+ * @param prefix the name of directory
+ */
+ public void checkBucketWithPrefixExists(String bucketName, String prefix) {
+ try {
+ s3Client.listObjects(bucketName, prefix);
+ } catch (AmazonS3Exception e) {
+ if (e.getStatusCode() == 404) {
+ logger.info("get status 404, maybe not exists, ignore it");
+ } else {
+ logger.error(
+ "list bucket: " + bucketName + " failed, please create
them by yourself or check permissions.");
+ throw e;
Review Comment:
Is it better if we just call listObjects method withOut try-catch? Since
this exception is thrown again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]