0

A support ticket has been raised whereby a mac user saved a file from an email, then uploaded it to our web based system. By default, when doing this the mac does not save the file with a 3 letter file extension.

While this caused our system some initial problems (it looks at the file extension to work out what kind of icon to show), these can be worked around easily.

However, I just know if we patch this behaviour, we will soon end up getting a ticket complaining that these files cannot be opened on a Windows based machine.

I think we have 3 options:

  1. Allow users to upload files with no extensions, and leave them to deal with the mess

  2. If a file with no extension is uploaded, show a dropdown and ask the user to pick what kind of file it is, then rename it for them. The downside of this, is if the user picks the wrong option, the file will open in the wrong application on Windows.

  3. Block uploading of files with no extensions, and insist they rename the file, adding the correct extension, then upload.

What is the best option for dealing with a situation like this?

5
  • 1
    A possible fourth option might be to use some software to figure out the extension for you based on the contents. See these questions on the Stack network (Q1, Q2, Q3, Q4)
    – Becuzz
    Oct 22, 2015 at 13:42
  • 1
    Why should the name on the user's local machine have anything to do with the filename on the server? That opens up a couple of security-related questions.... Why do you think extensions should be three letters long? Are you aware of the concept of a MIME type, and utilities such as the BSD file program to guess the type?
    – amon
    Oct 22, 2015 at 13:51
  • @Becuzz - Your comment could be expanded into a pretty good answer. Oct 22, 2015 at 14:14
  • @DanPichelman It probably can. When I get a few minutes I'll have to do that.
    – Becuzz
    Oct 22, 2015 at 14:22
  • @amon - yes, bad wording on my part in the question. We don't assume it's 3 characters. I'm aware of MIME, and also from initial research it seems it is not always correct (particularly with DOCX files, which would be the vast majority of files) Oct 22, 2015 at 14:47

1 Answer 1

4

I don't think that any of those options sound particularly good (at least as a first line of defense). No one is going to want to deal with the mess of either remembering what kind of files those things are later or being stopped all the time to rename files.

A different approach would be to use some software or a library to try to figure out what the file is without having to involve the user. After looking at these questions on the Stack network (Q1, Q2, Q3, Q4) it looks like there are at least a few solutions. One uses a program called TrID to identify the files (you could possibly shell out to it if it doesn't have a way to integrate directly into your code). Another listed a C# library (Urlmon) that seems to do an ok, but kind of limited job of identifying files.

I would try to identify the files by one of these means first. Only if that failed would I prompt the user to pick a file type or rename it. That should make it fairly user friendly and only bother them when you just can't do any more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.