nat
(Natalie T)
Janeiro 2, 2025, 5:04pm
16
Uma rápida atualização -
O ext_mime_db acima que usamos segue os Tipos de Mídia IANA definidos aqui - https://www.iana.org/assignments/media-types/media-types.xhtml . Infelizmente, isso significa que mp4 é corretamente application/mp4
Embora, olhando mais a fundo nossa implementação do uploader S3, eu vejo que estamos adicionando o cabeçalho Content-Disposition "attachment" para praticamente qualquer upload que não seja uma imagem, mas parece que ele foi pensado apenas para ser adicionado para svgs. Usar "attachment" faria com que o conteúdo fosse baixado em vez de aberto em uma nova aba. Para vídeos, é uma mistura de application/video e attachment que está causando isso.
Podemos pelo menos remover este cabeçalho, eu acho.
main ← use-inline-no-download
opened 05:01PM - 02 Jan 25 UTC
Back then in https://github.com/discourse/discourse/commit/31e31ef44973dc4daaee2… f010d71588ea5873b53, we added the [Content-Disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) headers so that SVGs get downloaded instead of get run in the browser. Inadvertently, this also causes other attachments like pdfs and videos to be downloaded instead of heeding the "Open in new tab" option that users choose in the browser.
### Problem video with `Content-Disposition: attachment`:
https://github.com/user-attachments/assets/f05d388f-4454-4615-9d5a-7a0a66fe3b52
When the header is removed, the default value is `"inline"`, this allows the browser to perform as requested. This also applies to other file types like pdfs, allowing users to "Open in new tab" and view them in the browser instead of always downloading them.
Existing tests (https://github.com/discourse/discourse/pull/10205) already do check that SVGs remain downloaded. Some existing tests written for PDFs have been modified to cater for SVGs instead, when there was a bug in defining the filenames per https://github.com/discourse/discourse/pull/10108
3 curtidas