superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.7k stars 316 forks source link

[feature] Save media to bucket with correct Content-type #3350

Closed prplecake closed 2 days ago

prplecake commented 4 days ago

Is your feature request related to a problem ?

It appears that media uploaded to S3-compatible buckets all get uploaded with a content-type: application/octet-stream. So using the new CDN redirect URL setting (#2574), attempting to view images via the CDN causes the browser to download the file instead of displaying the image.

The presigned URLs correctly accounted for content-type, but those aren't used when using the CDN redirect.

Describe the solution you'd like.

Files should be saved to the bucket with a proper content-type if we can detect it.

Describe alternatives you've considered.

Using edge rules to set the content-type header based on file extension. This doesn't seem like the correct place to do this.

Additional context.

Serving the images inline works fine, this is only a problem when "Opening image in new tab" or otherwise directly accessing the image URL.

tsmethurst commented 3 days ago

Thanks for this! This is really a bug imo, we should be using the correct content type when uploading, so I'll see if we can fix this for 0.17.0 :)

NyaaaWhatsUpDoc commented 3 days ago

i think this might be one that i need to handle @tsmethurst, i have a feeling it'll be something in the go-storage library