Skip to content

Commit 8b22226

Browse files
authored
Fix sending the right content-type for note images (#3091)
1 parent ddbb981 commit 8b22226

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

model/vfs/vfsafero/thumbs.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ func (t *thumbs) ServeNoteThumbContent(w http.ResponseWriter, req *http.Request,
156156

157157
func (t *thumbs) makeName(imgID string, format string) string {
158158
dir := imgID[:4]
159-
name := fmt.Sprintf("%s-%s.jpg", imgID, format)
159+
ext := ".jpg"
160+
if format == consts.NoteImageOriginalFormat {
161+
ext = ""
162+
}
163+
name := fmt.Sprintf("%s-%s%s", imgID, format, ext)
160164
return path.Join("/", dir, name)
161165
}

model/vfs/vfsswift/thumbs_v2_v3.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (t *thumbsV2) ServeThumbContent(w http.ResponseWriter, req *http.Request, i
126126
defer f.Close()
127127

128128
w.Header().Set("Etag", fmt.Sprintf(`"%s"`, o["Etag"]))
129+
w.Header().Set("Content-Type", o["Content-Type"])
129130
http.ServeContent(w, req, name, unixEpochZero, f)
130131
return nil
131132
}
@@ -185,6 +186,7 @@ func (t *thumbsV2) ServeNoteThumbContent(w http.ResponseWriter, req *http.Reques
185186
defer f.Close()
186187

187188
w.Header().Set("Etag", fmt.Sprintf(`"%s"`, o["Etag"]))
189+
w.Header().Set("Content-Type", o["Content-Type"])
188190
http.ServeContent(w, req, name, unixEpochZero, f)
189191
return nil
190192
}

0 commit comments

Comments
 (0)