Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed patchObject ignoring ContentType and ContentEncoding #1430

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions fakestorage/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,11 @@ func (s *Server) patchObject(r *http.Request) jsonResponse {
}

var payload struct {
Metadata map[string]string `json:"metadata"`
CustomTime string
Acl []acls
ContentType string
ContentEncoding string
Metadata map[string]string `json:"metadata"`
CustomTime string
Acl []acls
}
err := json.NewDecoder(r.Body).Decode(&payload)
if err != nil {
Expand All @@ -1024,6 +1026,8 @@ func (s *Server) patchObject(r *http.Request) jsonResponse {

var attrsToUpdate backend.ObjectAttrs

attrsToUpdate.ContentType = payload.ContentType
attrsToUpdate.ContentEncoding = payload.ContentEncoding
attrsToUpdate.Metadata = payload.Metadata
attrsToUpdate.CustomTime = payload.CustomTime

Expand Down
5 changes: 3 additions & 2 deletions internal/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (g *Server) GetBucket(ctx context.Context, req *pb.GetBucketRequest) (*pb.B
TimeCreated: timestamppb.New(bucket.TimeCreated),
}
return grpc_bucket, nil
///return GetBucketFromBackend(g.backend, req.Bucket)
}

func (g *Server) DeleteBucket(ctx context.Context, req *pb.DeleteBucketRequest) (*pb.Empty, error) {
Expand Down Expand Up @@ -148,7 +147,9 @@ func (g *Server) UpdateObject(ctx context.Context, req *pb.UpdateObjectRequest)

func (g *Server) PatchObject(ctx context.Context, req *pb.PatchObjectRequest) (*pb.Empty, error) {
attrs := backend.ObjectAttrs{
Metadata: req.Metadata.Metadata,
Metadata: req.Metadata.Metadata,
ContentType: req.Metadata.ContentType,
ContentEncoding: req.Metadata.ContentEncoding,
}
_, err := g.backend.PatchObject(req.Bucket, req.Object, attrs)
return &pb.Empty{}, err
Expand Down