Message Boards

File Extension appears twice

Zarina Omurova, modified 6 Years ago.

File Extension appears twice

New Member Posts: 8 Join Date: 11/23/17 Recent Posts
Hi to everyone,

I am using Liferay EE 6.2, and had an issue with uploaded Files into Liferay portal. When i did upload files with a capitalized Extension (which can be any ... pdf,doc,csv..) like "Test.XXX" after downloading this file there was additional extension which looked like "Test.XXX.xxx" afterwards. If i'm not wrong that is a piece of code which is responsible In Liferay-Sourcecode, a method sendFile() in the WebServerServlet.java class.

String fileName = fileVersion.getTitle();
		String extension = fileVersion.getExtension();
		if (Validator.isNotNull(extension) &&
			!fileName.endsWith(StringPool.PERIOD + extension)) {
			fileName += StringPool.PERIOD + extension;
		}


So my conclusion is, as file extension is ".xxx", but uploading File has a capitalized extension ".XXX", additional ".xxx" extension will be added to the file, and you'll get "Test.XXX.xxx". If you upload a file with an extension "test.xxx" is everything ok, without the second extension to the File. We did implemented some workaround for us, just wanted to ask it here if someone else also have had this issue? Is it a Bug in Liferay or normal Liferay behavior, or i might understand smth wrong?

must note, I'm pretty new to liferay, so maybe I did wrong conclusion.

Would be thankful for any Explanation.

Thank you
thumbnail
David H Nebinger, modified 6 Years ago.

RE: File Extension appears twice

Liferay Legend Posts: 14914 Join Date: 9/2/06 Recent Posts
Well, the bug of course is that except for old DOS systems, you should not be using capitalized extensions on filenames.

Only windows is case-insensitive for extension, every other OS and even the web itself is case sensitive. For example, an image tag as <img src="/o/my-portlet/img/team.png" /> is going to fail miserably if the file is team.Png or team.PNG or Team.png or ...

So the convention is to use file extension as all lower case because that is the most common format used, and windows is quite happy to use lower case because it just doesn't care either.