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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate ContentType field on create/modify ops #1141

Merged
merged 3 commits into from May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions fakestorage/object.go
Expand Up @@ -993,9 +993,10 @@ func (s *Server) updateObject(r *http.Request) jsonResponse {
}

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

attrsToUpdate.Metadata = payload.Metadata
attrsToUpdate.CustomTime = payload.CustomTime

attrsToUpdate.ContentType = payload.ContentType
if len(payload.Acl) > 0 {
attrsToUpdate.ACL = []storage.ACLRule{}
for _, aclData := range payload.Acl {
Expand Down
7 changes: 6 additions & 1 deletion fakestorage/upload.go
Expand Up @@ -485,7 +485,12 @@ func (s *Server) uploadFileContent(r *http.Request) jsonResponse {
obj.Crc32c = checksum.EncodedCrc32cChecksum(obj.Content)
obj.Md5Hash = checksum.EncodedMd5Hash(obj.Content)
obj.Etag = fmt.Sprintf("%q", obj.Md5Hash)
obj.ContentType = r.Header.Get(contentTypeHeader)
contentTypeHeader := r.Header.Get(contentTypeHeader)
if contentTypeHeader != "" {
obj.ContentType = contentTypeHeader
} else {
obj.ContentType = "application/octet-stream"
}
responseHeader := make(http.Header)
if contentRange := r.Header.Get("Content-Range"); contentRange != "" {
parsed, err := parseContentRange(contentRange)
Expand Down