Allow to preview pdf instead of download
GopherJ opened this issue ยท 9 comments
GopherJ commented
Allow to preview pdf instead of download
svenstaro commented
You mean you'd like to view PDFs directly in the browser instead of having the browser offer you to download the PDF?
SF73 commented
tylerthecoder commented
I would like this too. I am trying miniserve --header "Content-Disposition:inline"
and I think it is getting overwritten.
GopherJ commented
@svenstaro yes, like mozilla's pdf.js, users can choose if they would like to download or not later
svenstaro commented
I think the overwriting might be done by actix components. Can someone check out the code path? I'm not sure when I can get to it.
GopherJ commented
GopherJ commented
I applied the following patch in actix-files to make it worked
diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs
index d7795ba7..308cf702 100644
--- a/actix-files/src/named.rs
+++ b/actix-files/src/named.rs
@@ -134,7 +134,9 @@ impl NamedFile {
mime::IMAGE | mime::TEXT | mime::AUDIO | mime::VIDEO => DispositionType::Inline,
mime::APPLICATION => match ct.subtype() {
mime::JAVASCRIPT | mime::JSON => DispositionType::Inline,
- name if name == "wasm" || name == "xhtml" => DispositionType::Inline,
+ name if name == "wasm" || name == "xhtml" || name == "pdf" => {
+ DispositionType::Inline
+ }
_ => DispositionType::Attachment,
},
_ => DispositionType::Attachment,
svenstaro commented
Could you post the patch? If it gets merged, we will automatically benefit. Might need to make it configurable though.