Harjo,
I solved part of the problem by moving the files that I want to open somewhere under webapps/root folder, so that I can use the showUrl() to show the file directly from the server into the client browser.
But I still don't understand, what you wrote before:
in webclient you can just do: plugins.file.writefile('myfile.pdf', vBinaryData)
than the webclient does the rest for you, popup that file for you.
because I don't see the webclient doing all the rest for me
In Servoy 5 the plugins.file.writeFile() method was changed so that it writes on the client (that is what I understood).
So that means that the following coding must work. I don't see any reason why this shouldn't work:
- Code: Select all
/**
* @properties={typeid:35,uuid:"9E24DCA9-AE93-4B2C-AE1B-D2B4C56C0A80"}
*/
var _output = null;
/**
* @properties={typeid:35,uuid:"FF41BA01-09B6-47D4-9173-ADB5B58BACD4"}
*/
var _server_path = 'D:\\Servoy_51\\application_server\\server\\webapps\\ROOT\\attachments\\globis\\35\\7\\4\\2\\7425E933-B28A-4539-A650-749D857B5D1B.pdf';
/**
* @properties={typeid:24,uuid:"8AC21BAC-A82B-4900-9711-2F9E3C7E1F25"}
*/
function onShowDocument()
{
var _server = plugins.it2be_tools.server()
_output = 'Get server object\n';
_output += 'Read binary\n';
var _binary = _server.readFile(_server_path)
if (! _binary)
{
_output += '... Failed\n';
return;
}
_output += '... OK\n';
var _tmp_file = 'C:\\Temp\\myFile.pdf'
var _tmp_file2 = 'myFile.pdf'
var _ok = plugins.file.writeFile(_tmp_file, _binary)
_output += 'Binary file written to ' + _tmp_file + '\n';
if (! _ok)
{
_output += '... Failed\n';
return;
}
_output += '... OK\n';
_output += '... Size = ' + _binary.length + '\n';
_ok = plugins.file.writeFile(_tmp_file2, _binary)
_output += 'Binary file written to ' + _tmp_file2 + '\n';
if (! _ok)
{
_output += '... Failed\n';
return;
}
_output += '... OK\n';
_output += '... Size = ' + _binary.length + '\n';
_output += 'Show in browser: ' + 'file:///' + utils.stringReplace(_tmp_file, '\\', '/') + '\n'
_ok = application.showURL('file:///' + utils.stringReplace(_tmp_file, '\\', '/'), '_blank')
if (! _ok)
{
_output += '... Failed\n';
return;
}
_output += '... OK\n';
_output += 'Show in browser: ' + 'file:///' + utils.stringReplace(_tmp_file2, '\\', '/') + '\n'
_ok = application.showURL('file:///' + utils.stringReplace(_tmp_file2, '\\', '/'), '_blank')
if (! _ok)
{
_output += '... Failed\n';
return;
}
_output += '... OK\n';
}
The output shows the following:
- Code: Select all
Get server object
Read binary
... OK
Binary file written to C:\Temp\myFile.pdf
... OK
... Size = 467493
Binary file written to myFile.pdf
... OK
... Size = 467493
Show in browser: file:///C:/Temp/myFile.pdf
... OK
Show in browser: file:///myFile.pdf
... OK
And I don't find the myFile.pdf on my client PC (not in Downloads directory, not in C:\Temp)
And there is not a new browser window shown (not even with message 'file not found')
I checked also my server directories. Also on the server in the C:\Temp directory I don't find this file.
As far as I can see all this is correct Servoy javascript and I really don't understand why this isn't working.
FireFox, Safari (for windows) and Chrome show the same behavior
IE shows message about popup-window but no pdf file shown either. But there is a message about file not found (the file that is not in C:\Temp)
And there is not a single errormessage in the log on the adminpages.
I really don't see what is wrong here
This is Servoy version 5.1.4 -build 964