-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDF not possible to be viewed in the browser #867
Comments
Strange as this was fixed in your #144 issue. I have one email that has
And it does open properly in my browser. You can modify the following code and hope to find the issue. snappymail/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Raw.php Lines 147 to 154 in 974adb7
Maybe start with something like: // https://github.com/the-djmaze/snappymail/issues/144
if ('.pdf' === \substr($sFileNameIn,-4)) {
$sContentTypeOut = 'application/pdf'; // application/octet-stream
error_log("Output {$sFileNameIn} forced PDF");
} else {
$sContentTypeOut = $sContentTypeIn
?: \SnappyMail\File\MimeType::fromFilename($sFileNameIn)
?: 'application/octet-stream';
error_log("Output {$sFileNameIn} as {$sContentTypeOut}");
} |
I've modified the file Raw.php and added the code you suggested. Unfortunately, nothing popped up in the logs, even with log level 7 (=debug). Then I've modified the file as follows, because I wanted to be sure, that the program enters the error_log("ContentTypeIn {$sContentTypeIn} FileNameIn {$sFileNameIn} FileHashIn {$sFileHashIn}");
if (!empty($sFileHashIn)) {
$this->verifyCacheByKey($sRawKey);
// https://github.com/the-djmaze/snappymail/issues/144
if ('.pdf' === \substr($sFileNameIn,-4)) {
$sContentTypeOut = 'application/pdf'; // application/octet-stream
error_log("Output {$sFileNameIn} forced PDF");
} else {
$sContentTypeOut = $sContentTypeIn
?: \SnappyMail\File\MimeType::fromFilename($sFileNameIn)
?: 'application/octet-stream';
error_log("Output {$sFileNameIn} as {$sContentTypeOut}");
} But even with that I don't get any log output. Strange... Do you have an idea what else I could try? |
I've overlooked that there is another part a bit lower. snappymail/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Raw.php Lines 197 to 206 in 974adb7
|
Even if I add the error_log statements in this part, I don't get any logs. When activating the debug mode, I get the following, but I doubt, this will help much... |
My Raw.php file (had to rename it to Raw.txt in order to upload it) meanwhile looks as follows, but I don't get any output in the log (log level 4, debug mode activated). |
I've made a change to better log it. Use that and disable |
Wonderful, now I get log output. It shows the following: |
I think i found the issue with above commit. |
Fantastic! I've applied the patch and now it works like a charm again. Thank you very much! |
Describe the bug
PDFs should have the option to be viewed in the browser or to be downloaded.
PDF with no option to be viewed in the browser
----boundary_2799_4e1e27b0-e322-4f60-97c3-45bf9cd8e113
Content-Type: application/octet-stream; name="2022-000182500_a.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
X-EC0D2A8E-5CB7-4969-9C36-46D859D137BE-PartID: {A7EC3E57-0EE9-40EC-821A-16B5CC8340DF}
PDF with option to be viewed in the browser
--b66120d3-6d65-4e54-a6cb-f7dfb8e086a1-1
Content-Type: application/pdf;
name="180717_factsheet.pdf"
Content-Disposition: attachment;
filename="180717_factsheet.pdf"
Content-Transfer-Encoding: base64
Please complete the following information:
Additional context
The problem does not exist in SnappyMail 2.22.5.
The text was updated successfully, but these errors were encountered: