How does streamFilesToServer works ?

Questions, tips and tricks and techniques for scripting in Servoy

Re: How does streamFilesToServer works ?

Postby ptalbot » Thu Sep 23, 2010 6:00 pm

Hi Scott,

to create an 'uploads' folder in /server/webapps/ROOT/, the server plugin is relying on a path relative to the executable.

On WIndows/Linux launched from developer, this path resolves correctly, but on Mac OS X, it doesn't since the executable is located in the Servoy.app bundle: Servoy.app/Contents/MacOS so the plugin was falling back to the home of the current user (have a look inside yours, you should have and uploads folder in there with your transferred files).

I have corrected this so that it take the Mac path into account, try the attached jar.

Johan: a patch follows ;)
Attachments
file.jar
(64.16 KiB) Downloaded 284 times
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How does streamFilesToServer works ?

Postby Thunder » Mon Oct 18, 2010 6:48 pm

Hi Patrick

I am trying to use streaming too, but it seems not to be working on my machine. I need to stream a blob in the database to the desktop of the client. I have tried to do this:

Code: Select all
   var dir = plugins.file.showDirectorySelectDialog();
   if (dir){
         plugins.file.streamFilesFromServer(dir, image);
      
         }


but it simply does nothing..
Is there any documentation other than the sample included in Servoy 5.2?

Thanks

Bevil
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London

Re: How does streamFilesToServer works ?

Postby Harjo » Mon Oct 18, 2010 8:12 pm

Bevil

this version does not do blobs, only streaming file to/from server file based! (not blob-based)
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: How does streamFilesToServer works ?

Postby Thunder » Mon Oct 18, 2010 9:04 pm

Hey Harjo

It ONLY works with files? is there any way to work around it? write a blob to a local server temp file first and stream that? or would that undo the benefit of the streaming plugin?

I am in a desperate situation at the moment... My client's in production system has stopped functioning because the datastream plugin has an error:
Failed: Server returned HTTP response code: 500 for URL:x.x.x.x:8080/servoy-service/StreamServiceServlet/


I have spent all day trying to troubleshoot this, to no avail, it just doesn't work any more. In desperation, I tried to do the streamfilesfromserver thing, but if that is a dead end, I'll have to continue fighting with datastream plugin.

:(

Bevil
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London

Re: How does streamFilesToServer works ?

Postby Harjo » Mon Oct 18, 2010 9:19 pm

have you contacted IT2BE?
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: How does streamFilesToServer works ?

Postby ptalbot » Mon Oct 18, 2010 9:23 pm

Hi Bevil,

Yes, as the name of the plugin implies, it works with files!

Depending on the client, you COULD write a temp file on the server and stream that, but writing a temp file will use a server path if your client is a web client, a batch processor or a headless client, because these ones really run in a process on the server, saving directly from a smart client would defeat the purpose since you would have to stream the data to the server first before being able to stream them to your client! ;)

Just make sure the place your save your temp file is located inside the default folder of the file plugin and then your will be able to stream to your client.

Hope this helps,
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How does streamFilesToServer works ?

Postby jcompagner » Mon Oct 18, 2010 9:27 pm

what are you trying to do here?
Code: Select all
   var dir = plugins.file.showDirectorySelectDialog();
   if (dir){
         plugins.file.streamFilesFromServer(dir, image);
     
         }


first you ask on the client to show the file chooser to select a directory..

then you get that dir and then you ask to stream files from the server, but the first argument should be the file on the server.

but database streaming, we already have that that is just loading in the record and asking for that data. Then servoy will stream that from the db to the client for you.

streaming blobs from the client to the server is also easy to do, first just create a temp file, write it and then stream it.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How does streamFilesToServer works ?

Postby Thunder » Mon Oct 18, 2010 9:40 pm

Hi Johan

What I am trying to do is stream a file from a blob in the database. I didn't realise that this plugin only deals with files on the server, I misunderstood its purpose.

I originally had the system streaming data directly, but these are 60MB tif files, and as I recall, there was a memory issue (and a database lock up during the delivery of the data) if I simply load it from a blob. Is this no longer a problem in 5.2? (when I did this some years ago, I think it was on Servoy 2.2).

That said, what is the best way to stream data from a blob on the server to a file on the client?

Thanks for getting back to me.

Bevil
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London

Re: How does streamFilesToServer works ?

Postby jcompagner » Tue Oct 19, 2010 10:19 am

you could also use a headless client for this
just call a method on it that will return the byte[] to the callback method when it is done.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: How does streamFilesToServer works ?

Postby Marco R. » Tue Oct 19, 2010 10:50 am

Hi all!

If I stream a file into the default path(/uploads under ROOT path)all works fine but if I try to configure the destination stream path by servoy admin page then something goes wrong..
The main problem is that if I try to put whatever path into the server plugin property than this property completely disappear..to make it visible again I have to go into servoy.properties and remove the line with the plugin configuration.

I'm in windows environment for now(xp and 7),I've tried with this property value:

"C:\","C:/","/mySubFolderUnderROOT","mySubFolderUnderROOT","\mySubFolderUnderROOT" ,
"/mySubFolderUnderUploads" ,"mySubFolderUnderUploads" ,"\mySubFolderUnderUploads" ,
"uploads\mySubFolder".

So now my question is: Am I making something wrong? Why the servoy server file plugin property disappear if I fill it?

Thanks in advance


Marco
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How does streamFilesToServer works ?

Postby ptalbot » Tue Oct 19, 2010 2:02 pm

Hi Marco,

the fact that the property disappears from the admin page is a known bug that has been fixed and will be available in the next Servoy update.
In the meantime, you can set the path in the servoy.properties file, the bug doesn't affect anything else than the visibility of that property in the admin page, so everything else will work as normal.

Hope this helps,
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How does streamFilesToServer works ?

Postby Marco R. » Tue Oct 19, 2010 3:13 pm

Ok Patrick!

Thanks as always!

For anyone that use the webclient and want know more about the use of UploadData in servoy ,see here: http://forum.servoy.com/viewtopic.php?f=3&t=14920
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How does streamFilesToServer works ?

Postby Marco R. » Fri Oct 22, 2010 4:02 pm

Hi Patrick,


When I specify a destination folder that doesn't exist so the function "streamFilesToServer" will create it!(this is a great thing).
But this not happen into the web client..
So I've try to make it by myself and I with the line code:
Code: Select all
plugins.file.getRemoteFolderContents('/')
I can retrive the remote folder status.
My question is: "createFolder" function works on webClient?If yes: How can I create a remote folder without know the remote file struct?(I don't know for example where servoy installation is put,a good way could be to have something that can give me back the remote path or that point directly on remote home-file-plugin-path).

Off course if exist a way to make the function "streamFilesToServer" to create the remote destination folder as do into the smart client would be better.


Thanks in advance

Marco
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

Re: How does streamFilesToServer works ?

Postby ptalbot » Fri Oct 22, 2010 4:22 pm

Marco R. wrote:When I specify a destination folder that doesn't exist so the function "streamFilesToServer" will create it!(this is a great thing).
But this not happen into the web client..

It should work in web client too, if not then there is a bug somewhere.
I will have a look.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How does streamFilesToServer works ?

Postby Marco R. » Fri Oct 22, 2010 5:39 pm

If can help,the error that I receive is:

Code: Select all
java.io.IOException: Impossibile trovare il percorso specificato


by my translation:
Code: Select all
java.io.IOException: Impossible to find the specified path


If I create the missing folder thant all works fine.


Thanks


Marco
Marco Rossi
Freelance

Main development environment: Servoy 6.1.6 - 7.4.3, Java 1.6u45,7u71 Windows 7/CentOS
Marco R.
 
Posts: 203
Joined: Thu Mar 19, 2009 12:37 pm

PreviousNext

Return to Methods

Who is online

Users browsing this forum: No registered users and 10 guests