streamFileToServer

Hi

I am trying to stream files to the server via the smart client. The plugin provided by Servoy appears to default all files uploaded to the root/uploads directory. I would like to be able to stream files to a folder that is external of the Servoy root ie on an attached S3 volume, is there a way to do this ? I have tried symlinks and specifying fully qualified paths without success.

Many thanks
Gordon

The smart client doesn’t have access to the file system of the server for obvious reasons.
What you can do is start a headless client with the headless client plugin after the streaming is complete. The headless client runs server-side and can move the files from root/uploads to the other volume.

Hi

Thanks, that makes sense, I had thought about the idea of some sort of Perl script to do just that watch the folder and move stuff as it arrives. Headless client would also be a good option, I did not think it had a file/folder watcher so will go and investigate.

Cheers
Gordon

With our UserManager plugin that is possible… You could give that a try.

Joas:
The smart client doesn’t have access to the file system of the server for obvious reasons.
What you can do is start a headless client with the headless client plugin after the streaming is complete. The headless client runs server-side and can move the files from root/uploads to the other volume.

you can also stream to what ever folder you like on the server!, just set the path, in your servoy-admin page…

Harjo:
you can also stream to what ever folder you like on the server!, just set the path, in your servoy-admin page…

This is a good idea but still needs some intervention due to the fact that we have several clients on the web server which is the destination. I think the idea of either a headless or perl solution is looking good right now. I am hoping I can find one pre done as its Linux, pity its not a Mac it would be the prefect job for Otto the Automator !! …perhaps we will have to create Jan the Servoy Man - :)

patrick:
With our UserManager plugin that is possible… You could give that a try.

Interesting I was actually just looking at your Filewatcher, not UserManager …

The UserManager offers JSServerFiles, which are just like Servoy’s JSFile objects, but on the server. You can stream from any JSFile to any JSServerFile.

Joas:
The smart client doesn’t have access to the file system of the server for obvious reasons.
What you can do is start a headless client with the headless client plugin after the streaming is complete. The headless client runs server-side and can move the files from root/uploads to the other volume.

Having looked at the various options I have decided this one fits the bill the best. I am however struggling to understand how to monitor the progress and trigger the headless client once all the files are uploaded.

This example is provided, and shows how to report the process back to the console, the issue is how do you pass information from your upload script to the variable monitor ? Essentially I want to be able to allow the user to select a folder containing several images and upload these to the server. Once the upload has completed to trigger the headless client to move the images. IF anything goes wrong to alert the user and the system administrator.

Many thanks
Gordon

application.output('total transferred: ' + monitor.getTotalTransferredBytes() + ' / ' + monitor.getTotalBytesToTransfer());
	application.output('current file: ' + monitor.getCurrentTransferredFileName() + ' ( ' + monitor.getCurrentFileIndex() + ' / ' + monitor.getTotalFilesToTransfer() + ' )');
	application.output('current bytes transferred: '+monitor.getCurrentTransferredBytes() + ' / ' + monitor.getCurrentBytesToTransfer());
	if (monitor.isCanceled()) {
		application.output('canceled!')
	}
	if (monitor.isFinished()) {
		application.output('finished!')
	}

Gordon:
I am trying to stream files to the server via the smart client. The plugin provided by Servoy appears to default all files uploaded to the root/uploads directory. I would like to be able to stream files to a folder that is external of the Servoy root ie on an attached S3 volume, is there a way to do this ? I have tried symlinks and specifying fully qualified paths without success.

You can do this with Servoy’s file streaming directly. Just set the servoy.FileServerService.defaultFolder to “/” and then fully qualify your destination:

// mac server example
var monitor = plugins.file.streamFilesToServer(fileOBJ, "/Volumes/S3/some_directory/some_file_name.txt", CALLBACK_method_name)

Which also allows you to set the path depending on your client.

Gordon:
Once the upload has completed to trigger the headless client to move the images. IF anything goes wrong to alert the user and the system administrator.

The “CALLBACK_method_name” parameter in my example above is the method that will run when all uploading is done. So do all your post processing in that method.

I found file streaming to be a major PITA to get up to speed on. But we’re doing some pretty crazy stuff with it now that we have all the nuances figured out so well worth the trouble. I did a coding session on it a while back that you might find helpful. Good luck.

Thanks David will give this a try

Gordon

david:

Gordon:
I am trying to stream files to the server via the smart client. The plugin provided by Servoy appears to default all files uploaded to the root/uploads directory. I would like to be able to stream files to a folder that is external of the Servoy root ie on an attached S3 volume, is there a way to do this ? I have tried symlinks and specifying fully qualified paths without success.

You can do this with Servoy’s file streaming directly. Just set the servoy.FileServerService.defaultFolder to “/” and then fully qualify your destination:

// mac server example

var monitor = plugins.file.streamFilesToServer(fileOBJ, “/Volumes/S3/some_directory/some_file_name.txt”, CALLBACK_method_name)




Which also allows you to set the path depending on your client.

don’t run tomcat then in a user that can do much! Because 1 hack and through a client one can completely read your whole filesystem or overwrite everything he wants…

When streaming files to a linux folder we are getting:

-rw-r–r–

…permissions set by default. I may have overlooked it but is there a way to set the permissions of the file that is streamed using Servoy OR is this a serverside issue resulting in my looking in the wrong hole. The reason this is flagging up now is clients are unable to delete files via Servoy with these permissions which is now a requirement.

Server is Ubuntu Linux 12.04
Servoy 6.1.14

Cheers
Gordon

Did you find a solution to this?

Unless you start up Servoy server under a different user than the one that originally created the files – those permissions should work.

swingman:
Did you find a solution to this?

sadly not a nice one, Servoy is running with standard login and permissions so it should have been ok as David suggested in next post. The only way I could get it to work was to call a perl script to do the delete !! Which worked but is horrible ;(