Description of issue or problem I’m having:
Hi OJS team,
I encounter a fatal problem when I download docx/doc/xls/xlsx/rar/zip… files form OJS generated link, and open files, it will show file corrupted. I’m not sure why is this happened, It happened suddenly at one day.
Is it database corrupt? Since I know that database have record file type. Please help to check this issue, it is very urgent.
Steps I took leading up to the issue:
Upload file via OJS.
Download file via OJS.
What I tried to resolve the issue:
I did some test:
I’m sure that upload file is correct which by binary compare from file explorer on my server.
Just encounter to use OJS link, such as: URL/index.php/journals/$$$call$$$/api/file/file-api/download-file?.. to download file.
The PHP log no show any error during download and finish file.
Currently, I only found pdf file can normal download and open without any error.
Application Version - e.g., OJS 3.1.2:
ojs-3.1.2-1, PHP 7.0.33
Additional information, such as screenshots and error log messages if applicable:
I have use binary to compare with between download from OJS and original file, this is a docx file as shown below,
OJS does not alter or store the files you upload in a database. It does, however, store the mime type in the submission_files table. I’d suggest reviewing the stored mime types for those files and see if they are correct. Those mime types are generated by the operating system on the server and you may need assistance from your systems administrator if they are not correct.
you may also want to try using an FTP client to download the files out of your files_dir directory as specified in your config.inc.php file and see if you can open them that way. That will remove OJS entirely from the process and prove that your files themselves are not corrupt.
That’s a new one for me. I’ve never seen OJS modify a file in that way when it is being downloaded.
You may want to ask your systems administrator and find out if they are using any Apache or other webserver modules that may be encoding or otherwise altering files.
Have any developers made any changes to any of your OJS code? It’s possible that they’ve introduced whitespace which may cause this problem.
Does the problem only occur with docx/zip/rar type files? Those files are essentially zip files (even docx and xlsx). If you’re using an apache module like mod_deflate you may be corrupting those files by compressing them twice. Can you download PDFs okay?