summaryrefslogtreecommitdiff
path: root/internal/media/processingmedia.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-11-04 13:58:15 +0000
committerLibravatar GitHub <noreply@github.com>2024-11-04 14:58:15 +0100
commit8f288f1689376a8cf6ab7f431e862eb870765342 (patch)
tree42442833af06948eb3ec9f7710ed35b809cd6992 /internal/media/processingmedia.go
parent[chore]: Bump github.com/minio/minio-go/v7 from 7.0.79 to 7.0.80 (#3511) (diff)
downloadgotosocial-8f288f1689376a8cf6ab7f431e862eb870765342.tar.xz
[bugfix] determine mime-type to use during ffprobe evaluation stage, don't bother checking against file extension (#3506)
* determine mime-type to use during ffprobe evaluation stage, don't bother rechecking by file extension * set mjpeg content-type * fix up tests expecting differing default values
Diffstat (limited to 'internal/media/processingmedia.go')
-rw-r--r--internal/media/processingmedia.go20
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,