Skip to content

Commit

Permalink
Fixed patchObject ignoring ContentType and ContentEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
UnAfraid committed Dec 15, 2023
1 parent 445e8cf commit be30dba
Show file tree
Hide file tree
Showing 2 changed files with 11 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
6 changes: 4 additions & 2 deletions internal/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ 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)
// /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 +148,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 be30dba

Please sign in to comment.