streamFileToServer

Questions, tips and tricks and techniques for scripting in Servoy

streamFileToServer

Postby Gordon » Tue Jul 12, 2011 10:44 am

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
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby Joas » Tue Jul 12, 2011 10:58 am

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.
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: streamFileToServer

Postby Gordon » Tue Jul 12, 2011 11:04 am

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
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby patrick » Tue Jul 12, 2011 11:15 am

With our UserManager plugin that is possible... You could give that a try.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: streamFileToServer

Postby Harjo » Tue Jul 12, 2011 11:24 am

Joas wrote: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 Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: streamFileToServer

Postby Gordon » Tue Jul 12, 2011 11:33 am

Harjo wrote: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 - :)
Last edited by Gordon on Tue Jul 12, 2011 11:39 am, edited 1 time in total.
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby Gordon » Tue Jul 12, 2011 11:36 am

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

Interesting I was actually just looking at your Filewatcher, not UserManager ...
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby patrick » Tue Jul 12, 2011 11:43 am

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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: streamFileToServer

Postby Gordon » Wed Jul 13, 2011 3:20 pm

Joas wrote: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

Code: Select all
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 McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby david » Mon Jul 18, 2011 9:22 pm

Gordon wrote: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:

Code: Select all
// 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.
Last edited by david on Mon Jul 18, 2011 9:38 pm, edited 2 times in total.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: streamFileToServer

Postby david » Mon Jul 18, 2011 9:35 pm

Gordon wrote: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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: streamFileToServer

Postby Gordon » Mon Jul 18, 2011 9:58 pm

Thanks David will give this a try

Gordon
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Re: streamFileToServer

Postby jcompagner » Tue Jul 19, 2011 9:59 am

david wrote:
Gordon wrote: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:

Code: Select all
// 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...
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: streamFileToServer

Postby Gordon McLean » Fri Apr 05, 2013 12:54 pm

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
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 253
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Re: streamFileToServer

Postby swingman » Mon May 20, 2013 5:53 pm

Did you find a solution to this?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Next

Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests