nat
(Natalie T)
2 Gennaio 2025, 5:04pm
16
Solo un rapido aggiornamento -
L’ext_mime_db sopra che utilizziamo segue i tipi multimediali IANA definiti qui - https://www.iana.org/assignments/media-types/media-types.xhtml . Sfortunatamente, ciò significa che mp4 è correttamente application/mp4
Anche se, esaminando ulteriormente la nostra implementazione dell’uploader S3, vedo che stiamo aggiungendo l’intestazione Content-Disposition "attachment" per quasi tutti i caricamenti che non sono immagini, ma sembra che fosse inteso solo per gli svg. L’uso di "attachment" comporterebbe il download del contenuto anziché l’apertura in una nuova scheda. Per i video, è un mix di application/video e attachment che causa questo.
Possiamo almeno rimuovere questa intestazione, credo.
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
2 Mi Piace