FTP Client in the cloud.

0
Currently I've implemented a solution using an FTP Client module. When I deploy it locally, it works fine. When it's transferred to the cloud however, the not everything works as expected. When I try to send files using the proper credentials I get the following error: Errortype: java.security.AccessControlException Errormessage: access denied (java.io.FilePermission /srv/cloud/slots/tr10000/deploy/data/files/00/25 read) Stacktrace: ----------------------------------------- com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: Exception occured for document ITEMS_BASIC_1.xml with action SEND. at com.mendix.core.Core.execute(SourceFile:232) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Exception occured for document ITEMS_BASIC_1.xml with action SEND. at hC.b(SourceFile:218) Caused by: Exception occured for document ITEMS_BASIC_1.xml with action SEND. at ftpconnection.helpers.HandleFileFtp.handleFile(HandleFileFtp.java:100) Caused by: access denied (java.io.FilePermission /srv/cloud/slots/tr10000/deploy/data/files/00/25 read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkRead(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2571) at com.enterprisedt.net.ftp.FileTransferClient.uploadFile(FileTransferClient.java:857) at com.enterprisedt.net.ftp.FileTransferClient.uploadFile(FileTransferClient.java:831) at ftpconnection.helpers.HandleFileFtp.handleFile(HandleFileFtp.java:63) at ftpconnection.actions.SendFileDocumentToFTPLocation.executeAction(SendFileDocumentToFTPLocation.java:49) at ftpconnection.actions.SendFileDocumentToFTPLocation.executeAction(SendFileDocumentToFTPLocation.java:23) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.execute(SourceFile:226) at ln.a(SourceFile:69) at mt.a(SourceFile:72) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.executeSync(SourceFile:203) at lo.a(SourceFile:60) at mt.a(SourceFile:72) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.executeSync(SourceFile:203) at lo.a(SourceFile:60) at mt.a(SourceFile:72) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.execute(SourceFile:226) at gn.execute(SourceFile:186) at jd.a(SourceFile:319) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:170) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:161) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:160) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:156) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192) When I analyse this, this looks I don't have read access to the file in question in the cloud. Probably because I have to send the file using an absolute path in the java code. Does anyone know how to solve this? Regards, Ferry
asked
2 answers
1

You should use Core.getFileDocumentContent instead of trying to access filedocument files directly by path.

answered
1

The FTP client does not support using an InputStream sadly enough. Roeland reply got me thinking:

You should use Core.getFileDocumentContent instead of trying to access filedocument files directly by path.

The solution I came up with is the following: I use the InputStream from getFileDocumentContent() to generate a File in the Mendix Temporary folder based on the name of the FileDocument in Mendix. After generating the File, I send it to the FTP location and afterwards, I delete the generated Temporary File.

Thanks Roeland.

answered