Why Microsoft Edge opens CSV instead of showing save dialog? - csv

Here's the example.
In all browsers except Microsoft Edge when user clicks on link then he prompted to save CSV file. Microsoft Edge, unexpected for me, opens it in browser like normal text.
CSV file in example above have these headers:
Content-Type: text/csv
Content-disposition: attachment
Any idea how to force Microsoft Edge to show save dialog instead of opening CSV as plain text.

I tried here : https://support.spatialkey.com/spatialkey-sample-csv-data/
there is this link to a CSV : http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv
It is downloading on Microsoft Edge on my side (not showing it).
The header they use is this one :
Content-Type: application/x-csv
Can you try this ?

Related

Is there a possibility to change tab title when I show an native pdf

I will show an PDF in chrome. Direct (no html). But the tab title in chrome is the last part of my url (https://myservice/foo/baar/generate-pdf).
I send the PDF to the client via HTTP-Header:
Content-Disposition: inline, filename="test.pdf"
Is there a possibility to change tab title when I show an native pdf?
I tried this without success:
Search for title HTML-Header
PDF title Meta-Data (ignored by chrome)
The "Content-Disposition" Filename are ignored by chrome
Has anybody an idea?
Thanks!

Content-disposition inline filename not working

There are some old questions regarding this topic, but the issue I'm facing is just some days old so thought to create a new thread.
I am using the content-disposition inline combined with filename to open a PDF file directly in Browser.
content-disposition: inline; filename="MyFile.pdf"
Until a couple of days ago it was working fine in Chrome and Firefox, (I know that in old IE versions the filename parameter wouldn't work in inline), PDF was opening in browser with the correct (provided) filename.
Now it seems like the filename parameter isn't working anymore even for Chrome and Firefox. The PDF is opened correctly but created with a name from the last part of the URL, which in my case is just pdf (https://.../pdf).
If I switch to attachment instead of inline the filename works fine, file gets downloaded with the correct filename. Issue is that I need to open the file in browser and not download it.
Is inline with filename not anymore possible in Chrome and Firefox?
I am facing very similar problem lately.
Strangely, when making a POST request for PDF document, the filename is ignored. But if I make a GET request, everything works like before. PDF is shown correctly and SaveAs also works with correct filename.
I ended up making a redirect on the server side, so the last request is a GET.
Another thing I noticed is, when the user clicks on the Download (Save As) button in the browser's PDF viewer, the server gets another request for the document and serves the content again. The Print command however does not make another request and prints the content already in the PDF viewer.
Hope this info helps, even if only to let you know, you're not the only one with this problem.
Edit:
It turned out, that POST and GET requests did not have anything to do with the problem. The problem was Cache-Control: no-store header that prevented the browser to store the PDF content and forced it to make another request for the PDF content at Save As command. The POST command was not formed correctly the second time which resulted in "Network Error".
I removed no-store from the header and now everything works fine.
The new header looks like this:
Cache-Control: no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
I have found that in my environment, URLs containing basic authentication do not allow inline display of pdfs.

Chrome not recognising attachment filename

We have a web application which offers a file named L_2804071.key for download. The download works fine in Internet Explorer and FireFox but in Chrome it "loses" the filename and chrome does not seem to recognize the filename in the content-disposition header.
Here is the full header (identical in both browsers):
content-disposition: attachment; =?utf-16le?B?ZmlsZW5hbWU9TF8yODA0MDcxLmtleQ==?=
I don't know if this helps but if you decode =?utf-16le?B?ZmlsZW5hbWU9TF8yODA0MDcxLmtleQ==?= you get Wfilename=L_2804071.key which looks weird. Not sure where the "W" comes from but IE seems to work with it and downloads a file named L_2804071.key.
Fix the web application to return a Content-Disposition header field that follows the spec, your example is invalid (for starters, there's no "filename" parameter). Note that your example appears to use RFC2047-style encoding, which in general isn't used in Content-Disposition.
See http://greenbytes.de/tech/webdav/rfc6266.html for details.

Force browser to open file instead of prompting download

When clicking a PDF link in Firefox and Chrome, the file will sometimes be opened for in-browser viewing and sometimes prompt a "Save as" dialog.
If I wanted to force the link to always prompt a download I could use the download HTML5 attribute.
However, I want to do the opposite. I.e., force the links to always be viewed in the browser.
Sort of an inverse download attribute. Is there such a thing? :)
I'd prefer to not modify response headers when serving PDF documents - I want to be able to specify in markup what the browser behavior should be.
Thanks!
You can achieve that by setting the appropriate header (for instance, in case of PDF, the header will be Content-type: application/pdf;
With this header, the browser will know the mime-type of the file and display it if it is compatible with it.
Here you can see the headers for a PDF.
As a hint, what I like to do is to use some sort of controller (in case you are using a backend language) that handles the download. Hence, to download myNewProject.pdf I do
<a href='download.php?file=myNewProject.pdf&viewInBrowser=1'>Download!</a>
Then I can set the appropriate headers depending on the file type, or if I want to force download or view it in the browser...
I'm using Firefox in XP. I went to the OPTIONS under Tools and found Portable Document Format. Click on it and it will allow you to change the way PDF files are handled.
open the file in a Microsoft Word and save as html.

Force download a picture from Google Chrome without opening new tab

We want to allow a user to download a picture via a button from our website. We've got the basic download working ok (it saves it to the disk) but we do it by opening up a new window...
window.open('mypicture', '_blank');
Unfortunately this creates a new tab in Chrome which does not go away. We don't have the most sophisticated users and they might become confused if the screen suddenly goes blank.
We tried it with...
location.href='mypicture'
This works great in IE, but in Chrome it just ignores the download completely.
Is there any other way to force download the picture without opening a new window?
Ideally, you should send http header in order to prompt the picture to be downloaded like
Content-Disposition: attachment; filename="downloaded.jpg"
..so you should point your link to a PHP script (or whatever), which sends a picture with proper headers.
Perhaps this is a bug in Chrome (FF too)? I just tried it with a link and it works fine.
Download