diff options
Diffstat (limited to 'internal/media/processingmedia.go')
-rw-r--r-- | internal/media/processingmedia.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index 4c6670b06..894975a1b 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -186,8 +186,8 @@ func (p *ProcessingMedia) store(ctx context.Context) error { p.media.FileMeta.Original.Duration = util.PtrIf(float32(result.duration)) p.media.FileMeta.Original.Bitrate = util.PtrIf(result.bitrate) - // Set media type from ffprobe format data. - p.media.Type, ext = result.GetFileType() + // Set generic media type and mimetype from ffprobe format data. + p.media.Type, p.media.File.ContentType, ext = result.GetFileType() // Add file extension to path. newpath := temppath + "." + ext @@ -236,10 +236,10 @@ func (p *ProcessingMedia) store(ctx context.Context) error { // Determine if blurhash needs generating. needBlurhash := (p.media.Blurhash == "") - var newBlurhash string + var newBlurhash, mimeType string - // Generate thumbnail, and new blurhash if need from media. - thumbpath, newBlurhash, err = generateThumb(ctx, temppath, + // Generate thumbnail, and new blurhash if needed from temp media. + thumbpath, mimeType, newBlurhash, err = generateThumb(ctx, temppath, thumbWidth, thumbHeight, result.orientation, @@ -250,6 +250,9 @@ func (p *ProcessingMedia) store(ctx context.Context) error { return gtserror.Newf("error generating image thumb: %w", err) } + // Set generated thumbnail's mimetype. + p.media.Thumbnail.ContentType = mimeType + if needBlurhash { // Set newly determined blurhash. p.media.Blurhash = newBlurhash @@ -265,10 +268,6 @@ func (p *ProcessingMedia) store(ctx context.Context) error { ext, ) - // Get mimetype for the file container - // type, falling back to generic data. - p.media.File.ContentType = getMimeType(ext) - // Copy temporary file into storage at path. filesz, err := p.mgr.state.Storage.PutFile(ctx, p.media.File.Path, @@ -295,9 +294,6 @@ func (p *ProcessingMedia) store(ctx context.Context) error { thumbExt, ) - // Determine thumbnail content-type from thumb ext. - p.media.Thumbnail.ContentType = getMimeType(thumbExt) - // Copy thumbnail file into storage at path. thumbsz, err := p.mgr.state.Storage.PutFile(ctx, p.media.Thumbnail.Path, |