feat: stand-alone port s3 server (#6242)
* feat: single port s3 server * fix: unable to PUT files if not in root dir
This commit is contained in:
@ -299,7 +299,7 @@ func (b *s3Backend) PutObject(
|
||||
Mimetype: meta["Content-Type"],
|
||||
}
|
||||
|
||||
err = fs.PutDirectly(ctx, path.Dir(reqPath), stream)
|
||||
err = fs.PutDirectly(ctx, reqPath, stream)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// Make a new S3 Server to serve the remote
|
||||
func NewServer(ctx context.Context, authpair []string) (h http.Handler, err error) {
|
||||
func NewServer(ctx context.Context) (h http.Handler, err error) {
|
||||
var newLogger logger
|
||||
faker := gofakes3.New(
|
||||
newBackend(),
|
||||
@ -19,7 +19,7 @@ func NewServer(ctx context.Context, authpair []string) (h http.Handler, err erro
|
||||
gofakes3.WithLogger(newLogger),
|
||||
gofakes3.WithRequestID(rand.Uint64()),
|
||||
gofakes3.WithoutVersioning(),
|
||||
gofakes3.WithV4Auth(authlistResolver(authpair)),
|
||||
gofakes3.WithV4Auth(authlistResolver()),
|
||||
gofakes3.WithIntegrityCheck(true), // Check Content-MD5 if supplied
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,6 @@ package s3
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Mikubill/gofakes3"
|
||||
@ -15,7 +14,6 @@ import (
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/internal/setting"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
type Bucket struct {
|
||||
@ -150,15 +148,13 @@ func prefixParser(p *gofakes3.Prefix) (path, remaining string) {
|
||||
// }
|
||||
// }
|
||||
|
||||
func authlistResolver(list []string) map[string]string {
|
||||
authList := make(map[string]string)
|
||||
for _, v := range list {
|
||||
parts := strings.Split(v, ",")
|
||||
if len(parts) != 2 {
|
||||
utils.Log.Infof(fmt.Sprintf("Ignored: invalid auth pair %s", v))
|
||||
continue
|
||||
}
|
||||
authList[parts[0]] = parts[1]
|
||||
func authlistResolver() map[string]string {
|
||||
s3accesskeyid := setting.GetStr(conf.S3AccessKeyId)
|
||||
s3secretaccesskey := setting.GetStr(conf.S3SecretAccessKey)
|
||||
if s3accesskeyid == "" && s3secretaccesskey == "" {
|
||||
return nil
|
||||
}
|
||||
authList := make(map[string]string)
|
||||
authList[s3accesskeyid] = s3secretaccesskey
|
||||
return authList
|
||||
}
|
||||
|
Reference in New Issue
Block a user