Description of issue or problem I’m having:
Editors reported that when they uploaded a .csv dataset to the galleys of an article that it was being converted to .txt
Steps I took leading up to the issue (to reproduce the issue):
- Create new version of published article
- Add galley
- Select dataset as the Article Component
- Upload a .csv file
- Publish the new version
- Download the dataset
What I tried to resolve the issue:
- The editor saved the csv in MS Excel and uploaded an .xlxs file as a work around. OJS successfully provided the .xlxs file for download, but the authors would prefer that the data be published as .csv.
- I renamed the same file
example.nothing and OJS (appropriately) saved it as
- I ran
diff against the contents of the original .csv file provided by the editor and the .txt file that OJS provided for download. Their contents were identical.
Application Version - e.g., OJS 3.1.2:
This isn’t entirely the same issue, but this seems similar to what has been encountered here with the mime type not being correctly identified: .WMV galley files open as .ASX files in OJS 126.96.36.199 - #18 by NateWr
What you might want to do as a first step is check what the mimetype is as per this SQL query:
Thanks @rcgillis, that was really helpful.The mimetype is being stored as text/plain instead of text/csv in the
files table. When I use
file --mime-type -b against the .txt files download from OJS, I get text/csv. So the quick fix it seems like is going to be to just updating the the
mimetype field in the
Thanks, @IOPNdev - I’m going to get @NateWr to potentially weigh in on some suggested next steps, when he is available to comment, given that we’re seeing this in another context.
Thanks for the excellent report and reproduction steps, @IOPNDev. It sounds like it is the same issue as the .wmv files. This has been filed at WMV files are downloaded as ASX files in Firefox · Issue #7474 · pkp/pkp-lib · GitHub and I’ve added a comment that this is effecting .csv files too.
Can you tell me whether you’re able to reproduce this issue on Firefox and Chrome? Or just Firefox?
With the WMV issue, it looks like it is related to a quirk in the way that Firefox overrides the file extension based on the mimetype, rather than respecting the filename. At the moment I am waiting to see if there is any movement on Firefox’s side to adjust this. But if not we will implement a workaround in OJS.
@NateWr I’m still getting the same behavior in Chrome and Safari. I think other the main difference between what I’m seeing and the WMV issue (if I’m reading the WMV issue correctly) is that the the csv files are being recorded in the db incorrectly text/plain.
And updating the MIME type in the
files tables seems to resolve the issue.
The mimetype is one part of it. But OJS should still return response headers with the correct filename (including extension). The issue is that when there is a mimetype/extension mismatch, the browser seems to override the downloaded filename.
Either way the solution will probably be the same, unless the browser’s roll back that behaviour (which seems to be relatively new).