david:
thanks patrick! wasn’t 100% sure that you coded this part. very nice addition to servoy.
it turns out all the crazy issues i was having with the monitor and callback was user error: i was calling streamFilesFromServer() for each file in a directory instead of passing in an array of files to the function and calling it once. creating a situation where i had many streams going at the same time. not so good ![Smile :)]()
Yes, I guess the monitoring works best if you are using an array of files.
That being said, it’s true that you can use more than one thread by issuing more than one streamFilesToServer or streamFilesFromServer - if you are not interested in the feedback that’s good to know.
david:
one question i haven’t been able to figure out: can you stream directly to a variable? currently i’m creating temp files, streaming to those, then doing readTXTFile() on them.
No you can’t.
The whole deal of streaming files to and from server is to be able to stream files that wouldn’t fit into memory (think video files for example), the idea being that only a small buffer is needed to transfer big files. So streaming to a variable makes no sense with that use case in mind.
Maybe readTXTFile and readFile could accept a JSFile of type RemoteFile and read directly into a variable? - right now they don’t.
david:
- if you pass a sub folder that doesn’t exist to getRemoteFolderContents(), it returns the name of the folder you pass in. should probably return either nothing or an error code representing sub folder does not exist.
Yes, you are probably right. Maybe it should throw an Exception.
david:
- it’s not readily clear that the default uploads folder (“/uploads/”) is in the ROOT directory from the info on the admin page.
- setting a default folder on the admin page has to be a fully qualified path from the hard drive root. could be made more clear in the admin info.
Will see how I can make the info for the property clearer.
david:
- could use a function to return the servoy install directory on the server. gives a way to programmatically ensure that you are always working within the servoy directory.
There is getDefaultUploadLocation() (since 5.2.4) that will give you the path used by the plugin as the root of all uploads (“/” in relative notation)
Returning the servoy install directory won’t give you much more, in any case you cannot set the default upload location programmatically (for security reasons).
david:
- hidden directories are returned with plugins.file.streamFilesFromServer(option 2 for folders). not sure if this is a good or bad.
Not sure either. Right now the function doesn’t filter anything in the root upload location, it’s up to you whether you want to give access to your users or not.
david:
tip for people: when checking for file existence when streaming from the server (based on a path of type string), make sure to use the remote-convert-to-js file instead of the normal convert-to-js file. Since both functions return the same value when working in developer it’s worth noting:
plugins.file.convertToRemoteJSFile(directory + themesArray*.getName() + "/description.txt").exists()*
*```[/quote]*
*Yes, people need to understand that the JSFile that is returned by this function is really a different kind of JSFile than the one returned by convertToJSFile (which is why there is a different function).*
*Internally they are represented by a RemoteFile or a LocalFile class.*