mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-11-13 06:00:47 +08:00
- Default missing upload MIME types to application/octet-stream before passing streams to storage drivers. - Return HTTP 206 for successful ranged GET responses while preserving error statuses. - Add isolated response-status regression tests without database initialization. Signed-off-by: jyxjjj <16695261+jyxjjj@users.noreply.github.com> Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
29 lines
778 B
Go
29 lines
778 B
Go
// Credits: https://pkg.go.dev/github.com/rclone/rclone@v1.65.2/cmd/serve/s3
|
|
// Package s3 implements a fake s3 server for openlist
|
|
package s3
|
|
|
|
import (
|
|
"context"
|
|
"math/rand"
|
|
"net/http"
|
|
|
|
"github.com/OpenListTeam/gofakes3"
|
|
)
|
|
|
|
// Make a new S3 Server to serve the remote
|
|
func NewServer(ctx context.Context) (h http.Handler, err error) {
|
|
var newLogger logger
|
|
authPairs := authlistResolver()
|
|
faker := gofakes3.New(
|
|
newBackend(),
|
|
// gofakes3.WithHostBucket(!opt.pathBucketMode),
|
|
gofakes3.WithLogger(newLogger),
|
|
gofakes3.WithRequestID(rand.Uint64()),
|
|
gofakes3.WithoutVersioning(),
|
|
gofakes3.WithV4Auth(authPairs),
|
|
gofakes3.WithIntegrityCheck(true), // Check Content-MD5 if supplied
|
|
)
|
|
|
|
return redirectHandler(rangeStatusHandler(faker.Server()), authPairs), nil
|
|
}
|