nat
(Natalie T)
2 يناير 2025، 5:04م
16
تحديث سريع فقط -
ext_mime_db أعلاه الذي نستخدمه يتبع أنواع وسائط IANA Media Types المعرفة هنا - https://www.iana.org/assignments/media-types/media-types.xhtml . للأسف، هذا يعني أن mp4 هو بشكل صحيح application/mp4
على الرغم من ذلك، بالنظر إلى تطبيق S3 uploader الخاص بنا بشكل أعمق، أرى أننا نضيف رأس Content-Disposition \"attachment\" لكل تحميل تقريبًا ليس صورة، ولكن يبدو أنه كان مخصصًا فقط لملفات svgs. استخدام \"attachment\" سيؤدي إلى تنزيل المحتوى بدلاً من فتحه في علامة تبويب جديدة. بالنسبة لمقاطع الفيديو، فهو مزيج من application/video و attachment هو ما يسبب هذا.
يمكننا على الأقل إزالة هذا الرأس، أعتقد.
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 إعجابات