Here is some sample code:
var fileUUID = application.getUUID()
var fileName = "/pdf_print/" + fileUUID + ".pdf"
var tFile = plugins.file.createTempFile("print", ".pdf")
plugins.file.writeFile(tFile, pdfData)
plugins.file.streamFilesToServer(tFile, fileName);
We are printing a temp file from a printed form, then streaming it to the server to the subfolder, “pdf_print”. The servoy.FileServerService.defaultFolder is empty, so it should use the default ROOT/uploads folder. The Servoy server is Windows. When you use a Smart Client from Windows, everything works fine. When you use a Smart Client from Mac, it seems to think the upload/home folder is the Desktop on the Server. So it creates a new folder on the desktop called “pdf_print” and puts all the pdf files in there. So, its only a problem on mac.
The defaultServer is not set by clients, it is only set once at the server plugin’s initialization’s time.
So maybe there is a problem with the path of the tFile itself (in your example) which on mac is starting with / and could look from a windows server point of view as a relative path.
Will have a look with a mac smart client and see where it gets this strange path.
BTW, Have you tried setting the servoy.FileServerService.defaultFolder property to a proper path instead of leaving it blank to see if this solves the problem?
Leaving this one empty is asking the server plugin to do quite a lot of work to find the right path, so when you know where you want your files to go, I guess it’s always best to set this property than leaving it empty.
The default should really be considered as a fallback rather than something to use in production actually.
I was under the assumption that it was recommended to leave it default. I changed it to a hard coded path, and it is now working correctly on Mac. Thanks for the help!
Would you like me to still submit a case for this since it is still a bug according to the docs?
You can create a case, I’ll have a look anyway.
goldcougar:
I was under the assumption that it was recommended to leave it default. I changed it to a hard coded path, and it is now working correctly on Mac. Thanks for the help!
its the opposite!
That default path is just for you convenience but if you really use it ALWAYS set a path your self!
Depending on that upload dir in webapps/root shouldn’t be done! You should configure it your self to have a good write dir. That default is just the only real thing we can do
Except maybe the tomcat tmp dir (but that is really a temp dir also not very handy)
I already updated the docs that will go live with 6 for this.