Skip to content

Commit

Permalink
Fixed patchObject ignoring ContentType and ContentEncoding (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnAfraid authored Dec 19, 2023
1 parent 9084120 commit 0c31d15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 0c31d15

Please sign in to comment.