Utils / File Stream Plugin

I have this plugin that we use for general purpose stuff. So far, it has these methods implemented…

//Copy a file from the Servoy App Server to a Servoy Client. Use 1024 as default bufferSize. Returns “true” or “Error: msg”

plugins.DDC_Utils.copyFileFromAppServerToClient("/path/on/server/filename", "/path/on/client/filename", 1024);

//Download a file from a URL to a local file. Returns “true” or “Error: msg”

plugins.DDC_Utils.downloadURL("http://site.com/filename.pdf", "/path/on/client/filename");

//Converts Integer to Binary and then returns switch at Position

plugins.DDC_Utils.getSwitch(number Key, number Position)

//Returns a unique random number array of specified length, using numbers from min to max

plugins.DDC_Utils.getUniqueRandomArray(number min, number max, number length)

//Returns title case of each word in the string

plugins.DDC_Utils.getTitleCase("mr. smith");

//Still have a way to go on this one. Currently jus replaces new line with

plugins.DDC_Utils.textToHTML(myText);

An improvement I would like to make is to make the copyFileFromAppServerToClient more streaming. Currently it streams the file using buffers of a specified length from the server to the client through a RMI service. This is okay for normal downloads…However we would like to also use it for streaming audio files. So, something like a Quicktime Streaming Server, but as a Servoy plugin…so they can listen to the file as it downloads. If it cannot be done, we will have to actually use a streaming server, which will put it outside of Servoy (which we really don’t want to do since it currently uses Servoy’s RMI port to stream the file).

ddc_utils.jar (23.6 KB)

Some nice functions! Looks real every one of us has a plugin like that with general purpose utilities. I think what we should do is somehow organize a “Servoy Toolkit” (the name of our own general util plugin that I am willing to share parts of): An open source plugin (colection) that someone will maintain a bit. Maybe since Marcel was the first who offered his tools for free, we should vote for him as president :wink:? I could offer for example

  • formatFileSize: formats a file length to a String like 1.89 KB or 2.5 MB
  • escapeHTML (unescapeHTML): replace HTML characters such as > with their HTML entity reference (>)
  • unescapeHTML
  • Base64 encoder / decoder
  • getServers: Returns a multi dimensional String array of all server connections of the Servoy server. The single server connections consists of serverName, URL, driver, schema, user and password.
  • createUniqueValuesArray: Takes an array and filters out duplicate values. Returns a new array with only unique values.
  • escapeIllegalFileNameCharacters: Checks a file name for illegal characters (such as "/", ":", "*", …) and removes them.
  • reportWarning: Shows a warning message as red text in the status area of the application. The warning disappears after a few seconds.
  • Possible, but only if Marcel doesn’t offer that already: CSVWriter and Reader

So I think the idea could be that everybody brings in his code in whatever classes and somebody takes care of the “ToolkitProvider.class” and links all together. The developers provide tooltips, parameter description and sample code (if possible). Before a new version is published, we could do some sort of beta phase where the willing do some testing.

Basically, this means for all users of freeware plugins, that there is not too much work to be done when it comes to maintaining versions of the divers plugins. I already re-created some functionality from Marcels tools into my plugin, just not to have another file to maintain. So one big joint development.

How about that, plugin community?

Just a thought.

Nice idea guys…

And yes, the csv is part of the data plugin ;)

I second the vote for Marcel as president :)

I like the idea of combining…and I have no problem sharing. Marcel, if you are up to it, we can figure out how we want to put it together and I’ll send you whatever you need.

Please, I need to know if this plugin is for WebClient or it is just to smartclient?
thanks

in that case, I run it, I returned ‘true’ but fileN is where I should leave, what is the problem?