Set correct Content-Type
This commit is contained in:
parent
53e545ddc5
commit
e8b69fba03
|
@ -840,6 +840,10 @@ func (r *downloadRequest) fetchRemoteFile(
|
||||||
}
|
}
|
||||||
defer resp.Body.Close() // nolint: errcheck
|
defer resp.Body.Close() // nolint: errcheck
|
||||||
|
|
||||||
|
// If this wasn't a multipart response, set the Content-Type now. Will be overwritten
|
||||||
|
// by the multipart Content-Type below.
|
||||||
|
r.MediaMetadata.ContentType = types.ContentType(resp.Header.Get("Content-Type"))
|
||||||
|
|
||||||
var contentLength int64
|
var contentLength int64
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
var parseErr error
|
var parseErr error
|
||||||
|
@ -869,6 +873,8 @@ func (r *downloadRequest) fetchRemoteFile(
|
||||||
if !first {
|
if !first {
|
||||||
readCloser := io.NopCloser(p)
|
readCloser := io.NopCloser(p)
|
||||||
contentLength, reader, parseErr = r.GetContentLengthAndReader(p.Header.Get("Content-Length"), readCloser, maxFileSizeBytes)
|
contentLength, reader, parseErr = r.GetContentLengthAndReader(p.Header.Get("Content-Length"), readCloser, maxFileSizeBytes)
|
||||||
|
// For multipart requests, we need to get the Content-Type of the second part, which is the actual media
|
||||||
|
r.MediaMetadata.ContentType = types.ContentType(p.Header.Get("Content-Type"))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,7 +896,6 @@ func (r *downloadRequest) fetchRemoteFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
r.MediaMetadata.FileSizeBytes = types.FileSizeBytes(contentLength)
|
r.MediaMetadata.FileSizeBytes = types.FileSizeBytes(contentLength)
|
||||||
r.MediaMetadata.ContentType = types.ContentType(resp.Header.Get("Content-Type"))
|
|
||||||
|
|
||||||
dispositionHeader := resp.Header.Get("Content-Disposition")
|
dispositionHeader := resp.Header.Get("Content-Disposition")
|
||||||
if _, params, e := mime.ParseMediaType(dispositionHeader); e == nil {
|
if _, params, e := mime.ParseMediaType(dispositionHeader); e == nil {
|
||||||
|
|
Loading…
Reference in a new issue