diff options
author | 2024-09-26 12:43:10 +0000 | |
---|---|---|
committer | 2024-09-26 14:43:10 +0200 | |
commit | 53ee6aef0885b4055ef95bf4f20ee78fd381e333 (patch) | |
tree | a181b038dc969482b34690603328dd6b756a42fb /internal/media/processingmedia.go | |
parent | [chore] reduce number admin process workers (#3354) (diff) | |
download | gotosocial-53ee6aef0885b4055ef95bf4f20ee78fd381e333.tar.xz |
[bugfix] s3 media uploaded without content-type (#3353)
* update go-storage dependency, for S3Storage manually call PutObject() so we can set content-type
* update calls to PutFile() to include the contentType
Diffstat (limited to 'internal/media/processingmedia.go')
-rw-r--r-- | internal/media/processingmedia.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index 78c6c61a9..acd326457 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -261,10 +261,15 @@ 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, temppath, + p.media.File.ContentType, ) if err != nil { return gtserror.Newf("error writing media to storage: %w", err) @@ -286,10 +291,14 @@ 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, thumbpath, + p.media.Thumbnail.ContentType, ) if err != nil { return gtserror.Newf("error writing thumb to storage: %w", err) @@ -298,9 +307,6 @@ func (p *ProcessingMedia) store(ctx context.Context) error { // Set final determined thumbnail size. p.media.Thumbnail.FileSize = int(thumbsz) - // Determine thumbnail content-type from thumb ext. - p.media.Thumbnail.ContentType = getMimeType(thumbExt) - // Generate a media attachment thumbnail URL. p.media.Thumbnail.URL = uris.URIForAttachment( p.media.AccountID, @@ -320,10 +326,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) - // We can now consider this cached. p.media.Cached = util.Ptr(true) |