Compare commits

...

2 Commits

Author SHA1 Message Date
Derrick Hammer d913e0f7b2
fix: seek after mime read 2024-03-29 12:29:57 -04:00
Derrick Hammer 8ccd90825b
fix: wrong error handling 2024-03-29 12:28:46 -04:00
1 changed files with 8 additions and 1 deletions

View File

@ -2003,9 +2003,16 @@ func (s *S5API) downloadFile(jc jape.Context) {
detectedType, err := mimetype.DetectReader(file) detectedType, err := mimetype.DetectReader(file)
if err != nil { if err != nil {
s.logger.Error("error detecting mime type", zap.Error(err)) s.logger.Error("error detecting mime type", zap.Error(err))
}
_ = jc.Error(err, http.StatusInternalServerError) _ = jc.Error(err, http.StatusInternalServerError)
return
}
mimeType = detectedType.String() mimeType = detectedType.String()
_, err = file.Seek(0, io.SeekStart)
if err != nil {
s.logger.Error("error seeking file", zap.Error(err))
_ = jc.Error(err, http.StatusInternalServerError)
return
}
} }
if len(mimeType) == 0 { if len(mimeType) == 0 {