UPDATE: try fix move s3
All checks were successful
Build and Release / release (push) Successful in 1m7s
All checks were successful
Build and Release / release (push) Successful in 1m7s
This commit is contained in:
@@ -7,14 +7,16 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
ffconfig "history-api/pkg/config"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
"github.com/aws/aws-sdk-go-v2/config"
|
"github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||||
|
"github.com/aws/smithy-go/middleware"
|
||||||
|
smithyhttp "github.com/aws/smithy-go/transport/http"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
ffconfig "history-api/pkg/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UploadOptions struct {
|
type UploadOptions struct {
|
||||||
@@ -90,6 +92,20 @@ func NewS3Storage() (Storage, error) {
|
|||||||
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
|
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
|
||||||
o.BaseEndpoint = aws.String(endpoint)
|
o.BaseEndpoint = aws.String(endpoint)
|
||||||
o.UsePathStyle = true
|
o.UsePathStyle = true
|
||||||
|
o.APIOptions = append(o.APIOptions, func(stack *middleware.Stack) error {
|
||||||
|
return stack.Build.Add(middleware.BuildMiddlewareFunc(
|
||||||
|
"AddEmptyContentLength",
|
||||||
|
func(ctx context.Context, in middleware.BuildInput, next middleware.BuildHandler) (
|
||||||
|
out middleware.BuildOutput, metadata middleware.Metadata, err error,
|
||||||
|
) {
|
||||||
|
req, ok := in.Request.(*smithyhttp.Request)
|
||||||
|
if ok && req.Method == "PUT" && req.Header.Get("Content-Length") == "" {
|
||||||
|
req.Header.Set("Content-Length", "0")
|
||||||
|
}
|
||||||
|
return next.HandleBuild(ctx, in)
|
||||||
|
},
|
||||||
|
), middleware.After)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return &s3Storage{
|
return &s3Storage{
|
||||||
@@ -110,6 +126,7 @@ func (s *s3Storage) Move(ctx context.Context, src *MoveOptions, dest *MoveOption
|
|||||||
Bucket: aws.String(dest.Bucket),
|
Bucket: aws.String(dest.Bucket),
|
||||||
Key: aws.String(dest.Key),
|
Key: aws.String(dest.Key),
|
||||||
CopySource: aws.String(copySource),
|
CopySource: aws.String(copySource),
|
||||||
|
MetadataDirective: types.MetadataDirectiveCopy,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to copy object: %w", err)
|
return fmt.Errorf("failed to copy object: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user