Merge pull request #2388 from kmlebedev/fix_mime

fix mine detect
This commit is contained in:
Chris Lu 2021-10-18 10:23:23 -07:00 committed by GitHub
commit 825d76622b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,9 +39,12 @@ func init() {
func mimeDetect(r *http.Request, dataReader io.Reader) io.ReadCloser {
mimeBuffer := make([]byte, 512)
dataReader.Read(mimeBuffer)
r.Header.Set("Content-Type", http.DetectContentType(mimeBuffer))
return io.NopCloser(io.MultiReader(bytes.NewReader(mimeBuffer), dataReader))
size, _ := dataReader.Read(mimeBuffer)
if size > 0 {
r.Header.Set("Content-Type", http.DetectContentType(mimeBuffer))
return io.NopCloser(io.MultiReader(bytes.NewReader(mimeBuffer[:size]), dataReader))
}
return io.NopCloser(dataReader)
}
func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request) {