feat: 完成连接测试和新建s3连接函数

This commit is contained in:
loveuer
2024-09-26 22:35:43 +08:00
parent fcb2a349e7
commit 65f702c6e9
9 changed files with 178 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package handler
import (
"nf-disk/internal/ndh"
"nf-disk/internal/s3"
)
func ConnectionTest(c *ndh.Ctx) error {
@ -21,5 +22,13 @@ func ConnectionTest(c *ndh.Ctx) error {
return err
}
if req.Endpoint == "" || req.Access == "" || req.Key == "" {
return c.Send400(nil, "endpoint, secret_access, secret_key 是必填项")
}
if _, err = s3.New(c.Context(), req.Endpoint, req.Access, req.Key); err != nil {
return c.Send500(err.Error(), "连接失败")
}
return c.Send200("test success")
}