Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Download file
Download file [message #1763838] Sun, 21 May 2017 20:53 Go to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
don't work download file for safari correctly

this is generated header from RAP

HTTP/1.1 200
Date: Sun, 21 May 2017 20:44:30 GMT
Content-Type: application/octet-stream
Content-Length: 5469
content-disposition: attachment; filename="Nodes_234430.xlsx"

but file save as source url
start$%servicehandler=download&cid=dc0b50af&filename=41823199529678&type=export

chrome and firefox are ok
Re: Download file [message #1763839 is a reply to message #1763838] Sun, 21 May 2017 21:36 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
RAP is behaving like it should. Sounds like a Safari bug to me.

Have you tried "Content-Disposition" instead of "content-disposition" ? Headers aren't supposed to be case sensitive, but it could be the issue with Safari
Re: Download file [message #1763852 is a reply to message #1763839] Mon, 22 May 2017 08:14 Go to previous messageGo to next message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
change to lowercase and nothing. Strange but for PHP safari works ok

header('content-type: application/octet-stream');
header('accept-ranges: bytes');
header('content-length: ' . $size);
header('content-disposition: attachment; filename="' . $name_file . '"');

May be problem with JS script that I run from RAP

String js = "window.downloadFile = function (sUrl) {" + "if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1 || navigator.userAgent.toLowerCase().indexOf('safari') > -1) {" + "var link = document.createElement('a');" + "link.href = sUrl;" + "if (link.download !== undefined) {" + "var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);" + "link.download = fileName;" + "}" + "if (document.createEvent) {" + "var e = document.createEvent('MouseEvents');"
				+ "e.initEvent('click', true, true);" + "link.dispatchEvent(e);" + "return true;" + "}" + "}" + "window.open(sUrl);" + "return true;" + "};" + "window.downloadFile('" + url + "');";

		RWT.getClient().getService(JavaScriptExecutor.class).execute(js);

Re: Download file [message #1763887 is a reply to message #1763852] Mon, 22 May 2017 14:50 Go to previous message
Dmitry Dukhov is currently offline Dmitry DukhovFriend
Messages: 192
Registered: February 2013
Senior Member
ok fixed

remove "navigator.userAgent.toLowerCase().indexOf('safari') > -1" from JS script
Previous Topic:Deploying RAP Mail onto Apache Karaf
Next Topic:Open SWT.Shell and make display sleep
Goto Forum:
  


Current Time: Fri Apr 26 15:11:17 GMT 2024

Powered by FUDForum. Page generated in 0.04401 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top