Feature Requests: Remember and serve document type of uploaded attachments
The Problem
Picture this: A young moinmoin user figures out the answer to life, the universe, and everything, and uploads the file as an Attachment to the wiki.
Not being a geek, she doesn't realize the need to name it with a file extension like .jpeg or .doc. She names it "The answer to life, the universe and everything".
Thousands of acolytes try to download that file but Moinmoin won't serve it. Why? No document type configured.
Can you reproduce it here? See The answer - you can't view it, but definitely you can download it. It has 0 bytes, that is not an error.
- Your clarification is correct: you can download it but can't view it
Yes, because it has not a text/* mimetype, otherwise you could even view it. No extension -> application/octet-stream.
Frustrated, they give up on a great wiki or lots of time is wasted training each wiki user anew.
Tragically, this scenario repeats itself day in and day out. Many hours are wasted.
Suggested Solution
If her document was named something.doc, Moinmoin should remember that file extension and serve it with the appropriate MIME type.
MoinMoin already does this.
No - what I mean is, suppose you upload a file originally named something.doc but because of your link it is now named "The answer to life, the universe and everything", the original .doc filetype will be forgotten. It would be easy for Moinmoin to remember the extension of the file prior to renaming, if it's been omitted in the new file, so serve the right MIME type.
That's not easily possible. Either you first upload the file attachment, then you have no problem, as you won't rename it usually. But if you first save a page with attachment:whatever, that page will first be saved as is. And we won't edit the page afterwards to change the markup. We also do not store the mimetype separately now. So the only workaround is: don't do it
- Currently you are right, the only workaround is not to do it. It's a poor design to force people to read your mind about this, and stands in the way of Moin developing wider non-techy usage. It should be easy enough to store the original filetype or mime-type; I'm not sure what you're getting at by suggesting that because we don't do something, we shouldn't do it.
You may be used to uploading the file attachment before naming it in the page, but many people aren't. We don't need to edit the page to change the markup; we could simply store
- Otherwise, if no file extension is known, we can be smart and check the file content for certain strings that are indicative of JPEG or DOC or some other common formats, then serve that MIME type.
You think of something like the posix file command does. I looked at that already, but I was not too happy with the quality of the identification, it can be fooled easily. So this is only an option if we have good code for that.
- Probably a good last-choice alternative if we just don't have anything else to serve.
- moin2 will have a more sane solution to this
- If Moinmoin is going to insist on file extensions to serve an attachment, the Attach File interface should insist on one and should remind people to add the extension if they have forgotten. If some Moinmoin developer objects for some reason (I can't imagine why they would), make this a configurable setting.
- This is definitely a good idea. There should at least be a hint.
- Yay!
Is this features useful to most users or just to specific users? Yes, this feature is useful to everyone!
see development for version 2.0