Skip to content

Commit

Permalink
Custom metadata missing in Public and Signed URLs #1019 (#1020)
Browse files Browse the repository at this point in the history
* Custom metadata missing in Public and Signed URLs #1019

* Update fakestorage/object.go

Co-authored-by: Uddhav Kambli <ukambli@wayfair.com>
Co-authored-by: fsouza <108725+fsouza@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 28, 2022
1 parent 514832f commit a72af60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions fakestorage/object.go
Expand Up @@ -810,6 +810,9 @@ func (s *Server) downloadObject(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Goog-Generation", strconv.FormatInt(obj.Generation, 10))
w.Header().Set("X-Goog-Hash", fmt.Sprintf("crc32c=%s,md5=%s", obj.Crc32c, obj.Md5Hash))
w.Header().Set("Last-Modified", obj.Updated.Format(http.TimeFormat))
for name, value := range obj.Metadata {
w.Header().Set("X-Goog-Meta-"+name, value)
}

if ranged && !satisfiable {
status = http.StatusRequestedRangeNotSatisfiable
Expand Down
11 changes: 9 additions & 2 deletions fakestorage/object_test.go
Expand Up @@ -721,11 +721,18 @@ func TestServerClientObjectReaderError(t *testing.T) {

func TestServerClientObjectReadBucketCNAME(t *testing.T) {
url := "https://mybucket.mydomain.com:4443/files/txt/text-01.txt"
expectedHeaders := map[string]string{"accept-ranges": "bytes", "content-length": "9"}
expectedHeaders := map[string]string{"accept-ranges": "bytes", "content-length": "9", "x-goog-meta-marco": "Polo"}
expectedBody := "something"
opts := Options{
InitialObjects: []Object{
{ObjectAttrs: ObjectAttrs{BucketName: "mybucket.mydomain.com", Name: "files/txt/text-01.txt"}, Content: []byte("something")},
{
ObjectAttrs: ObjectAttrs{
BucketName: "mybucket.mydomain.com",
Name: "files/txt/text-01.txt",
Metadata: map[string]string{"Marco": "Polo"},
},
Content: []byte("something"),
},
},
}
server, err := NewServerWithOptions(opts)
Expand Down

0 comments on commit a72af60

Please sign in to comment.