Content disposition file name nor working in java - google-chrome

I have a code downloading excel, where I have content type as application/vnd.ms-excel and content disposition as below
Content-Disposition: attachment; filename=FILENAME.xls
In INTERNET Explorer I'm getting expected file but in chrome it's downloading plain text having all the content in excel as .file format
Please provide any suggestions.
Thanks in advance

Related

How can I code the HTML to force a browser to display a PDF from a linked web page?

I need to link a PDF from another website to my page. When I got the link in an email, it opens on a website (in Firefox, also works in Safari). Chrome wants to download the PDF. Can I apply any code in HTML or CSS to make it work properly, i.e. open a new page or tab and display the PDF there? Or open on my page, that's fine, too.
For PDF preview in a browser the following request headers should be specified:
Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"
For PDF or image download in a browser the following request headers should be specified:
Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"

Android Chrome - Unable to open PDF

I have a reponsive bootstrap application and while trying to open the pdf from mobile getting error. I am able to open the pdf from iphone however from android chrome it says "media not supported exception"
I have my application type as "octet-stream"
Thanks for your help.
The application/octet-stream MIME should only be used when you don't know what the file contents is going to be, as it's for arbitrary binary data. The receiver has to attempt to work out what type it is, based on it's content and/or file extension.
You should be always use the appropriate MIME if it is known:
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.PDF"

Why Microsoft Edge opens CSV instead of showing save dialog?

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 ?

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.

MFMailComposeViewController treats html attachment as image on iOS7

When I'm adding html file to the MFMailComposeViewController instance as an attachment the final email is generated with this attachment as embedded image on iOS7, however it worked fine on previous versions (iOS4, 5, 6).
[mailController addAttachmentData: fileData mimeType: #"text/html; Charset=utf-8" fileName:#"file.html"];
Final .eml content
<div><br><br>
<img src="cid:C7BFF544-754D-4322-A71C-12345667789" id="C7BFF544-754D-4322-A71C-12345667789"></div></body></html>
Content-Type: text/html; charset=utf-8;
name=file.html
Content-Disposition: attachment;
filename=file.html
Content-Transfer-Encoding: quoted-printable
Content-Id: <C7BFF544-754D-4322-A71C-12345667789>
When it is opened in gmail this attachment is displayed as 'not found' image.
It looks like native mail client treats this document as an embedded image however it's not.
I've tried to use different content-type combinations (application/pdf, charset-8/16) and it doesn't works. Only changing filename extension to for example '.shtml' resolves this issue. However changing filename is inapplicable for me.
Any thoughts?
Note: this application is built with iOS 6 SDK and XCode 4.
Do you have a signature being added to your email, like "Sent from my iphone" etc.?
Remove it and resend the email and attachment and see if the attachment suddenly appears.
There seems to be a problem with Apple Main and Outlook where Outlook will strip out attachments if there is any text added after the attachment has been added.
Sorry for the later response but shortly after posting I found an answer. Apple and Exchange have some issues and in order to fix this problem I had to make sure that all of the PDF docs I was adding to the message had more than one page. Simply removing the signature would work but was not valid solution. I appreciate the response and I hope this might help you as well. Just make sure the attachment has more then one page and everything will work great.