Skip to content

Commit

Permalink
Custom metadata missing in Public and Signed URLs fsouza#1019
Browse files Browse the repository at this point in the history
  • Loading branch information
Uddhav Kambli committed Dec 25, 2022
1 parent 10234b0 commit 0a1ed04
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 @@ -809,6 +809,9 @@ func (s *Server) downloadObject(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", strconv.FormatInt(contentLength, 10))
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))
for name, element := range obj.Metadata {
w.Header().Set("X-Goog-Meta-"+name, element)
}
w.Header().Set("Last-Modified", obj.Updated.Format(http.TimeFormat))

if ranged && !satisfiable {
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 0a1ed04

Please sign in to comment.