解决bucket name does not follow Amazon S3 standards. For more information refer http://docs.aws.amazon

在上传图片到Minio图片服务器的时候验证桶的名称发现汇报如下异常:

bucket name does not follow Amazon S3 standards. For more information refer http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

但是看配置文件都是感觉都是正常的。
其实大意了,你可以打断点发现这句错误是从哪儿抛出来的:

private void checkBucketName(String name) throws InvalidBucketNameException {
        if (name == null) {
            throw new InvalidBucketNameException("(null)", "null bucket name");
        } else {
            String msg;
            if (name.length() >= 3 && name.length() <= 63) {
                if (name.matches("\\.\\.")) {
                    msg = "bucket name cannot contain successive periods. For more information refer http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html";
                    throw new InvalidBucketNameException(name, msg);
                } else if (!name.matches("^[a-z0-9][a-z0-9\\.\\-]+[a-z0-9]$")) {
                    msg = "bucket name does not follow Amazon S3 standards. For more information refer http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html";
                    throw new InvalidBucketNameException(name, msg);
                }
            } else {
                msg = "bucket name must be at least 3 and no more than 63 characters long";
                throw new InvalidBucketNameException(name, msg);
            }
        }
    }

对就是这个校验bucket name的方法抛出的,他有个用正则来验证你表达式的判断

!name.matches("^[a-z0-9][a-z0-9\\.\\-]+[a-z0-9]$")

如果不符合这个表达式,那么就会报错,那这个表达式是什么意思呢,我也忘了,上网查了一下,大致意思匹配不符合从开头是字符后数字的字符串一直到字符的结尾处。
然后仔细检查了一下我的配置文件发现我的bucketname后边有个有个空格导致的
解决bucket name does not follow Amazon S3 standards. For more information refer http://docs.aws.amazon_第1张图片

你可能感兴趣的:(java,minio图片上传)