It would be nice to store all kinds of files, like: pdf, doc, xls etc… in the database. Not only media-files.
I don’t know if this is a limitation in the database, or a limitation in Servoy, but still… it would be nice!
It would be nice to store all kinds of files, like: pdf, doc, xls etc… in the database. Not only media-files.
I don’t know if this is a limitation in the database, or a limitation in Servoy, but still… it would be nice!
This is possible in 1.1 RC3
The steps are the following:
-create a media (blob) column (dataprovider)
-fill the dataprovider with the following script:
media_dp = application.readFile(‘c:/temp/’)
-to save the data(file) back to disk use:
application.writeFile(“c:/temp/xxxx.exe”,media_dp);
If you also want to store the filename use:
application.getLastFileName() //this returns the last filename (which is chosen by the user).
Note: A media column can hold any kind of binary data
WONDERFULL!!! I really like this future.
I have 2 questions:
1.) Saving the file to the localdisc, can this be done by an (File) dialog too??
2.) I have put a document: test.doc in the database, Now I want to start it rightaway. Can this be done?
Something like:
application.executeProgram(‘program’,‘c:/temp/test.doc’);
is not working.
yes use:
application.writeFile(“c:/temp”,media_dp);
or
application.writeFile(“”,media_dp);
yes, but write it to a file first (most pograms work only with a file)
Example:
application.writeFile(‘c:\temp\test.doc’,media_dp);
application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);
OkM-i that works.
(BTW the slashes are “/” not "" Else it don’t work!)
It would be nice to have a future to open files/documents. Right out of Servoy, so the OS starts automaticly the associated program.
Now you have to determ on every machine where Word,Excel,Acrobat Reader etc..etc..is installed, and believe me, on every machine, this can be different.
Is it possible?
about the slashes you are correct, it is possible to use '' but have to escape them with '' resulting in:
application.writeFile(‘c:\temp\test.doc’,media_dp);
about starting localmachine programs, there are the following options:
-default: application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);
-place all wanted programs in path system variable (on all clients), resulting in application.executeProgram(‘word.exe’,‘c:\temp\test.doc’);
-application.showURL(‘file:///C:/temp/test.doc’)
GREAT Thanks!
Jan Blok:
about starting localmachine programs, there are the following options:
-default: application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);
-place all wanted programs in path system variable (on all clients), resulting in application.executeProgram(‘word.exe’,‘c:\temp\test.doc’);
-application.showURL(‘file:///C:/temp/test.doc’)
I’ve problems in writing the path to the file (or application) under OSX.
I’m not sure to completely understand how java manages file paths: I have two discs, one of them with two partitions. So I expected to see three volumes in the open/save dialog box: but I only see the boot volume. Furthermore: this volume hasn’t the real volume name, but the computer’s name (the one you set up in system prefs, under Sharing panel).
I tried all the permutations, but I could manage to open a file with the application I want (only application.showURL works).
Who can give me more infos?
Thanks
Have I missed something here, or is hard-coding applications and paths thereto inviting nasty non-portabilities in to harrass us?
Surely a more portable approach would be to store a mime-type and provide a standard way for servoy to display/open/print/whatever the file, given the mime-type?
Regards,
Neale.
Hi Neale,
that would be very nice if Servoy had that function!
Riccardino:
I’ve problems in writing the path to the file (or application) under OSX.
I’m not sure to completely understand how java manages file paths: I have two discs, one of them with two partitions. So I expected to see three volumes in the open/save dialog box: but I only see the boot volume. Furthermore: this volume hasn’t the real volume name, but the computer’s name (the one you set up in system prefs, under Sharing panel).
The behaviour of the open/save dialog box is platform dependend and is managed by the Java VM (we cannot alter that behaviour)
Did you use the application.showFileSaveDialog(…) or application.showFileOpenDialog(…) ?
And the suggestions of Neale? Is that possible?
Neale:
Have I missed something here, or is hard-coding applications and paths thereto inviting nasty non-portabilities in to harrass us?
There are several different problems
-the file is stored in binary column, so no information about the file (mime-type) only bytes
-the Servoy client can be running on any platform (you just don’t know)
-As far as I know there is no way of generic opening files in applications based on mime type for each platform out there.
The only thing we could do is provide tags for temporary directory and userhome directory which you could use in your filename or url, something like ‘%%home.dir%%’ and ‘%%temp.dir%%’
So writing/opening html file in browser would look like:
application.writeFile(‘%%temp.dir%%/my_file.html’,data);
application.showURL(‘%%temp.dir%%/my_file.html’)
Any other suggestion how to open files in applications are is welcome.
Jan Blok:
There are several different problems
-the file is stored in binary column, so no information about the file (mime-type) only bytes
Indeed. The mime-type would have to be separately stored or otherwise known outside the BLOB.
Jan Blok:
-the Servoy client can be running on any platform (you just don’t know)
AFAICT, that’s the big redeeming feature of java
Jan Blok:
-As far as I know there is no way of generic opening files in applications based on mime type for each platform out there.
Perhaps that’s the case in J2SE/J2RE, I really don’t know.
But it appears that J2EE accomodates this.
See: http://java.sun.com/j2ee/1.4/docs/api/j … ndMap.html
If it really is only in J2EE, does that make things impractically complicated?
Regards,
Neale.
Jan Blok:
The behaviour of the open/save dialog box is platform dependend and is managed by the Java VM (we cannot alter that behaviour)
Did you use the application.showFileSaveDialog(…) or application.showFileOpenDialog(…) ?
I was using application.executeProgram: my purpose is to open a certain file with a certain application (that may be different to its default app). If I specify the path to the application (the “supposed” path I should say, since I don’t understand how path are managed by java), Servoy always gives me an error.
I tried, for instance, to open an Acrobat pdf file using OSX Preview: I wrote the path in almost 50 different ways (using also italian file names, for Preview and the Applications folder), but it doesn’t work.
Same thing with Applicaton.writefile and Application.readfile (so I think it’s a path related problem).
I have one more thing to add to the file discussion: is it possible to get the filename? It is nice to store files in the database, but it is not so helpful if you have no clue which file it is.
yep:
If you also want to store the filename use:
application.getLastFileName() //this returns the last filename (which is chosen by the user).
If you also want to store the filename use:
application.getLastFileName() //this returns the last filename (which is chosen by the user).
hmm. not in my version. i don’t even see the method and it throws me an error.
HM-i, you are right, the function is gone! I am sure it was there before because I have used it before, and expiremented with it!
Maybe Jan, can help us out!
application.getLastFileName() is replaced in 1.1rc4 with
var filename = application.showFileOpenDialog(…)