mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-10 15:28:08 -06:00
[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
This commit is contained in:
parent
b0fbc327f0
commit
53ee6aef08
15 changed files with 433 additions and 210 deletions
|
|
@ -216,10 +216,18 @@ func (p *ProcessingEmoji) store(ctx context.Context) error {
|
|||
"png",
|
||||
)
|
||||
|
||||
// Get mimetype for the file container
|
||||
// type, falling back to generic data.
|
||||
p.emoji.ImageContentType = getMimeType(ext)
|
||||
|
||||
// Set the known emoji static content type.
|
||||
p.emoji.ImageStaticContentType = "image/png"
|
||||
|
||||
// Copy temporary file into storage at path.
|
||||
filesz, err := p.mgr.state.Storage.PutFile(ctx,
|
||||
p.emoji.ImagePath,
|
||||
temppath,
|
||||
p.emoji.ImageContentType,
|
||||
)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error writing emoji to storage: %w", err)
|
||||
|
|
@ -229,6 +237,7 @@ func (p *ProcessingEmoji) store(ctx context.Context) error {
|
|||
staticsz, err := p.mgr.state.Storage.PutFile(ctx,
|
||||
p.emoji.ImageStaticPath,
|
||||
staticpath,
|
||||
p.emoji.ImageStaticContentType,
|
||||
)
|
||||
if err != nil {
|
||||
return gtserror.Newf("error writing static to storage: %w", err)
|
||||
|
|
@ -256,13 +265,6 @@ func (p *ProcessingEmoji) store(ctx context.Context) error {
|
|||
"png",
|
||||
)
|
||||
|
||||
// Get mimetype for the file container
|
||||
// type, falling back to generic data.
|
||||
p.emoji.ImageContentType = getMimeType(ext)
|
||||
|
||||
// Set the known emoji static content type.
|
||||
p.emoji.ImageStaticContentType = "image/png"
|
||||
|
||||
// We can now consider this cached.
|
||||
p.emoji.Cached = util.Ptr(true)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue