测试程序
func main() {
bucket := ceph.GetCephBucket("testbucket1")
//创建bucket
err := bucket.PutBucket(s3.PublicRead)
fmt.Printf("create bucket err:%+v
", err)
//查询bucket下指定条件的object keys
res, err := bucket.List("", "", "", 100)
fmt.Printf("object keys:%+v
", res)
//上传一个新对象
err = bucket.Put("/testupload/a.txt", []byte("just for test"), "octet-stream", s3.PublicRead)
fmt.Printf("upload err:%+v
", err)
//查询bucket下指定条件的object keys
res, err = bucket.List("", "", "", 100)
fmt.Printf("object keys:%+v
", err)
}
输出的错误如下
create bucket err:404 Not Found
object keys:<nil>
upload err:404 Not Found
object keys:404 Not Found
使用的连接
auth := aws.Auth{
AccessKey: "3S63LPNE7AYCYBAO42AB",
SecretKey: "taNYIE3NxsYrqoayoyGpHF89EAPzh0OFC3x9s2pI",
}
currRegion := aws.Region{
Name: "default",
EC2Endpoint: "http://172.16.133.130:8080",
S3Endpoint: "http://172.16.133.130:8080",
S3BucketEndpoint: "",
S3LocationConstraint: false,
S3LowercaseBucket: false,
Sign: aws.SignV2,
}
查询的用户确定没错
docker exec ceph-rgw radosgw-admin user info --uid=user1
"keys": [
{
"user": "user1",
"access_key": "3S63LPNE7AYCYBAO42AB",
"secret_key": "taNYIE3NxsYrqoayoyGpHF89EAPzh0OFC3x9s2pI"
}
],
不知道从何查起,dashboard正常访问
查看集群的状态 是健康
这个方法
//创建bucket
bucket := ceph.GetCephBucket("testbucket")
bucket.PutBucket(s3.PublicRead)
看了下源码实现
func (b *Bucket) PutBucket(perm ACL) error {
//*****
return b.S3.query(req, nil)
}
//******
req.path = "/" + req.bucket + req.path
//****
会拼路径,但是这个"testbucket",并不存在
纠结好久了,还望老师帮助?