Content-Disposition: attachment; filename="filename.pdf"
@ColinM Thanks buddy, you said it right, the issue when we debugged was the mime type was set while uploading the files. This should be done by the back-end team. I tried to get codes on how to add headers in java script but was not successful. Thanks, as I got the real idea cleared from you... :)
@Kailas I don't understand what you're trying to do.. The answer is referring to the headers that a server should send to a client when responding to an HTTP request for the PDF file. These headers have no effect on a file upload, you need to have the code behind the url set the headers every time it is downloaded by the client.
@PapickG.Taboada but then the user's system may not know the file type. E.g. some user's may have opted to "Always open files of this type" for PDF files. Perhaps if you want to override the user's preferences then octet-stream would be the way to go, but giving the correct type and a suggested filename is the "correct" way to provide a download.
EDIT: The quotes around the filename are required if the filename contains special characters such as filename.pdf which may otherwise break the browser's ability to handle the response.
To have the file downloaded rather than viewed:
To indicate to the browser that the file should be viewed in the browser:
hi @ColinM I am a bit confused here... we are having issues rendering the pdf, it just gives a scrambled text. where do we set the Content-Type: application/pdf Content-Disposition: inline; "filename.pdf"? 'cos, we upload it using angular-js code. So my question is should the content type be set before uploading? And also, we get only a link from the backend team, a url that gives the file path, that we open in new tab using:window.open(url, '_blank').focus();