Quantcast
Channel: Mendix Forum Questions
Viewing all articles
Browse latest Browse all 82391

Checking file type in JAVA action before or after commit doesn't work in cloud, but does work locally?

$
0
0

The following JAVA code isn't allowed to run in the cloud:

 

// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package myModule.actions;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import com.mendix.core.Core;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;

public class GetFileExtentionAsString extends CustomJavaAction<java.lang.String>
{
	private java.lang.String fileName;

	public GetFileExtentionAsString(IContext context, java.lang.String fileName)
	{
		super(context);
		this.fileName = fileName;
	}

	@Override
	public java.lang.String executeAction() throws Exception
	{
		// BEGIN USER CODE
		String fileType = null;
		File file = new File(fileName);
		try
		   {
		      fileType = Files.probeContentType(file.toPath());
		   }
		   catch (IOException ioException)
		   {
			   Core.getLogger("Error file type").info("Unable to determine file type for " + fileName + " due to exception " + ioException);
		   }
		   return fileType;
		// END USER CODE
	}

	/**
	 * Returns a string representation of this action
	 */
	@Override
	public java.lang.String toString()
	{
		return "GetFileExtentionAsString";
	}

	// BEGIN EXTRA CODE
	// END EXTRA CODE
}


Can anyone give a reason why this might be the case?


Viewing all articles
Browse latest Browse all 82391

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>