Download (TIFF) instead of opening by default in Internet Explorer - download

We are using Internet Explorer 11. In one of our webpage we got an anchor link which is pointing to a TIFF file. When I click the anchor link by default it is opening in the same page. We want to download (dialog box to save) instead of opening in the same window.
Is there any configuration available in IE?

See the Content-Disposition (RFC-2616) HTTP header, and use the value attachment (as opposed to the default value; inline):
If this header is used in a response [...] the user agent should not display the response, but directly enter a `save response as...' dialog.
Example:
Content-Disposition: attachment; filename="filename.tif"
See also Content-Disposition (MDN):
The first parameter in the HTTP context is either inline (default value, indicating it can be displayed inside the Web page, or as the Web page) or attachment (indicating it should be downloaded; most browsers presenting a 'Save as' dialog, prefilled with the value of the filename parameters if present).

Related

Is it possible to configure CKFinder as just a file browser without any upload functionality?

I want to be able to click on the image icon in CKEditor and be able to browser the local file system. I would like the chosen file to be passed to the editor just like the standard URL is. I want to use the base64image plugin to embed the image inline.
I have tried using CKFinder but, when I click the Browse Server button in the Image Properties dialog, I get an empty window with just 'run();' in the centre.
To enable CKFinder in read-only (gallery) mode, set the readOnly configuration option to true and pass it as a configruation option to the CKFinder.setupCKEditor function:
CKFinder.setupCKEditor( editor, {
readOnly: true
} );
This will disable the possibility to modify anything.
If you only want to disable uploads, you can disable modules related to upload operations:
CKFinder.setupCKEditor( editor, {
removeModules: 'FormUpload,Html5Upload,UploadFileButton'
} );
The second thing is to change Access Control settings in the server side connector by setting 'FILE_CREATE' to false so the uploads will be disabled also on the server side.

"Save As..." won't work in IE8

Part of the functionality of my intranet application is that a user needs to see some XML which has been generated. A new browser tab is opened, and the WebAPI controller streams XML.
This works fine, problem is when the user clicks on "Save As...", nothing happens.
If I place a static xml file on the server, browse to it and click "Save As..." then this works fine; so I don't see this as being caused by a group policy or desktop build error. This also works fine in a proper web browser.
The code to return the xml...
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(fpml, Encoding.UTF8, "text/xml"),
};
If you trick IE into thinking that it has a file, rather than dynamic content, then the "Save As..." feature will work as expected.
This can be done by simply adding a filename into the URL, i.e.
Instead of
http://myhost/myapp/api/getFpmlApi/?TradeId=234234
use
http://myhost/myapp/api/getFpmlApi/Fpml.xml?TradeId=234234

Bookmarklet to save file

Is is possible to use a bookmarklet in Firefox to save/open a file directly?
Many bookmarklets open a page on which one can click on a link to download the result. E.g. using a blob link. Is it possible to avoid this extra click and invoke the "save file" / "open file" dialog directly?
To trigger the "Save As" dialog for any resource (blob:, http:, whatever permitted scheme), use the download attribute of an anchor. This is supported since Firefox 20.
Example: A bookmarklet that presents the current page as a download:
javascript:(function() {
var a = document.createElement('a');
a.href = location.href;
a.download = 'filename.html';
document.body.appendChild(a);
a.click();
a.parentNode.removeChild(a);
})();
To trigger the Open dialog, create an <input type="file">, and click() it. For many examples, see Using files from web applications.
Should be possible if the bookmarklet sends you to a page where the web server sends the appropriate headers to force a download. Example:
Content-Disposition: attachment; filename="filename.zip"
Content-Type: application/zip

how to close IE9 browser session that has a popup message "Do you want to open or save file" displayed

on my web application, after clicking a download button, a popup message with content "Do you want to open or save "abc.txt" from this site?" with 3 buttons ("Open", "Save" & "Cancel") will be displayed at the bottom of page.
I'm trying to close/quit this browser session with below codes:
#driver.execute_script "window.onbeforeunload = function(e){};"
#driver.quit
However, the browser is NOT (but should be) closed. I'm working with Selenium Ruby Webdriver. Please guide me a way to resolve this problem. Thanks so much.
Note that with the above codes, I'm able to close IE9 browser that has the popup message "This page is asking you to confirm that you want to leave - data you have entered many not be saved" with "Leave Page" and "Stay on Page" buttons successfully. But, codes do NOT work in case the popup message with content "Do you want to open or save "abc.txt" from this site?" with 3 buttons ("Open", "Save" & "Cancel") displayed.
WebDriver has no control over these types of "Save file" dialog prompts.
Please peruse this article on this subject (note, his examples are in Java, but they can all be ported easily and with less code in Ruby). http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
Thus, I would recommend not even clicking the link in question and trying to deal with the dialog. Instead, grab the href value and initiate a Net::HTTP request to it like this SO response shows you how to do: https://stackoverflow.com/a/4581116/1221475 . You can then check the file for correct contents and such using standard Ruby and file parsers.
This is a hack by Dave Haefner. It is written for Java/Selenium combination, but you can easily convert it to Ruby syntax.
If you don't care if a file was downloaded or not and you want to confirm only that a file can be downloaded, you can use an HTTP request. Instead of downloading the file you'll receive the header information for the file which contains things like the content type and length. With this information, you can confirm the file is you expect.
String link = driver.findElement(By.cssSelector("download-link-element")).getAttribute("href");
HttpClient httpClient = HttpClientBuilder.create().build();
HttpHead request = new HttpHead(link);
HttpResponse response = httpClient.execute(request);
String contentType = response.getFirstHeader("Content-Type").getValue();
int contentLength = Integer.parseInt(response.getFirstHeader("Content-Length").getValue());
assertThat(contentType, is("application/octet-stream"));
assertThat(contentLength, is(not(0)));

Wicket - Internet Explorer double submit

I have a big problem with Internet Explorer 7 and 8.
SITUATION:
I have a FORM that build a Medical Prescription. When I hit the save button, the script saves the DomainObject on DB and set a boolean property (of panel where the form is added) called "saved" to true and a byte[] property called PDF with bytestream.
On RenderHead of Panel, I read this boolean and, if is true, I force the trigger of a hidden button with this code:
String js = "$('#" + printPDF.getMarkupId() + "').click();";
response.renderOnDomReadyJavaScript(js);
The button executes this code:
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(new ByteArrayResourceStream(pdf, "application/pdf"));
handler.setFileName("foo.pdf");
RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler);
This code work perfecly on FF and Chrome. The Browser download windows appears and the user can save the PDF on HD.
Unfortunally, Internet Explorer has that damn security behavior that is triggered when a site require something to download. That warning require a user validation. A yellow Bar appear and the user is force to hit "Download".
screenshot http://imageshack.us/a/img198/1438/securityg.jpg
When I hit Download File, the form is submitted again with the exact state I had when I hit save the first time. So no previous INSERT on DB is already committed; The Session is resetted to the previous state etc...
The result is a double INSERT on DB of the Domain Ojbect.
Any clue to resolve this?
The problem is that you click download link programaticly instead to redirect browser to an URL or open an URL by JS window.open(url). Click a link looks like an unwanted operation that is sometimes restricted by browser.

Resources