getRemoteFolderContents just doesn’t accept an absolute path.
It will only return the content of folders under the root declared in the servoy.FileServerService.defaultFolder server property (that you set in /servoy-admin/plugins)
So plugins.file.getRemoteFolderContents(‘/aFolderUnderTheRoot’) will work.
but plugins.file.getRemoteFolderContents(‘…/…/aFolderNotUnderTheRoot’) will not work
and neither will plugins.file.getRemoteFolderContents(plugins.file.getDesktopFolder());
The file server part of the file plugin has a security check that the client accessing the plugin is logged in at the appserver.
When you call plugins.file.getRemoteFolderContents() the client part will call the server part which throws the exception you see when the client is not logged in.
Basicially you cannot access the server side of the file plugin without being logged in.
what you do there is getting a remote directory on the server and as argument you give the your own local client side desktop dir…
That doesn’t make any sense.
It might work if your client has the same folder structure than the server, say your desktop folder (on the client) is c:/Users/Admin/Desktop and on the server you also have c:/Users/Admin/Desktop, and if you have set your servoy.FileServerService.defaultFolder to c:/ for example. But this will work for the wrong reason.
Because as Johan said, it doesn’t make sense: you are asking for the content of a server folder based on the path of the client!
Thank you for precise, detailed explanations Gentlemen!
New question:
How to copy file test.txt on server from test1 to test2 folder?
File exists: c:/test1/test.txt
servoy.FileServerService.defaultFolder is set to c:/
On client, it works with:
var myFolder = '/test1/';
var myFolder2 = '/test2/';
var folderFiles = plugins.file.getFolderContents( myFolder );
var fileToProcess = plugins.file.convertToJSFile( folderFiles[0] ); //simplification, loop in original code
var copySucc = plugins.file.copyFile( fileToProcess , myFolder2+"newFileName.txt" );
How to build analogy on the server? Will pick file(s) via getRemoteFolderContents method