Hi guys,
I need to be able to edit a file on the application_server folder on the server from within my code. The client is running on a different machine than the server obviously. I know I can get access to the upload folder and read and create files in there, but I don’t know how to get the path to the application_service folder itself! is there any Servoy functions or any plugin that has such a method to give me the path?
Cheers,
Siavash
Hi Siavas,
can use this code:
var urlTmpFolder = plugins.file.getDefaultUploadLocation()
In the urlTmpFolder you have the path of upload folder on your server.
Hi Siavash,
you’ll need the Usermanager plugin to do this.
You can download and register it (free of charge) at http://www.servoy-plugins.de
var _sFolder = plugins.UserManager.Server.servoyDirectory;
its a very bad approach to give the full paths of directories of a server install.
Then hackers could know already a lot of stuff…
How are you going to edit a file? How do you get the file in the first place??
Clients shouldn’t be able to get to any file on the server, that makes no sense and is a huge security issue.
Just use the file plugins remote files stuff. That one works in a relative dir somewhere on the servers file system. Only that relative dir on the server can be accessed from a client. Nothing outside that relative dir (its parents)
Hi Johan,
The reason I need to get access to the “application_server” folder is that I am trying to use the “servoyUpdater” plugin and implement a manual update process for the users. Currently, the plugin has the ability to update the solution automatically on schedule (the schedule can be set either on the servoy admin page or with a properties file which is located in the “application_server” folder of the server). But that’s not what we need to have. We have already asked from the plugin developers to give us a version that is programmable, so we can have control over when we check for the update whenever clients press the “check for update” button, not with a predefined schedule on the server, but we are not going to get it at this point. So, we needed to find a workaround to use the plugin, but the way we need it to function.
The plugin puts a properties file in the server application_server folder parent that contains a schedule to check a ftp server for a servoy file. The plugin reads the info when the server first is started and from that point it will go on the specified schedule. So, what I’m trying to achieve here is to change the properties file when the user requests the update. So, basically when they press the update button, I will change the properties file’s schedule to “now” and will restart the server. When the server comes back up, it will read the new info and checks the ftp folder for the update and if there is an update available, it will perform the update.
I know it is a bad practice to give access to server folder to clients but I have no other option as the properties file is there. I would appreciate it if you could give me another way of achieving my goal without doing this process.
Regards,
Siavash
A webclient could do that just fine, because that is on the server.
But how would you change the actual file or even read the servoy.properties file. even if you have a full path?
Which plugin would then give you the actual contents of that file? (looking from a smart client perspective)
For these kind of things don’t hack, make a good nice server plugin that does all this, and the smart client just tells the server what it should do.
jcompagner:
Which plugin would then give you the actual contents of that file? (looking from a smart client perspective)
For these kind of things don’t hack, make a good nice server plugin that does all this, and the smart client just tells the server what it should do.
Like I posted earlier: the UserManager plugin can do it.
If you’re looking for stuff in this area, most probably it’s just in there.
Great toolbox!
I’ll enhance the UserManager with more security for these kind of features. Currently, you have to be really careful because you can do almost anything over the remote interface.
I plan to enhance the remote plugin in a few weeks with server properties that allow you to
- specify user groups that have access
- specify users that have access
- specify users that have no access (like a demo account)
jcompagner:
A webclient could do that just fine, because that is on the server.
But how would you change the actual file or even read the servoy.properties file. even if you have a full path?
Which plugin would then give you the actual contents of that file? (looking from a smart client perspective)
For these kind of things don’t hack, make a good nice server plugin that does all this, and the smart client just tells the server what it should do.
Hi Johan,
I finally wrote a plugin to do the import function when the user asks for it, so there is no need to use the other plugin and try to make it work my way
So, no more hacking and no more headaches on how to access that text file to make the changes etc.
But still, it was good to know how to get application_server folder path on the server. (You are right thought, even having the file path wouldn’t help much as it’s not easily accessible unless it is on the local machine
)
mboegem:
Hi Siavash,
you’ll need the Usermanager plugin to do this.
You can download and register it (free of charge) at http://www.servoy-plugins.de
var _sFolder = plugins.UserManager.Server.servoyDirectory;
Thanks Marc,
I was already using the plugin but I didn’t know it has these informations in it as well. As you said, great toolbox ![Smile :)]()