Clicking the Chrome PDF Viewer download button directly downloading the server-side file.
I'm using ColdFusion server to generate the pdf file and view it in a separate tab with inline. PDF was correctly viewing in a tab but when clicking the download icon I can able to download that PDF file, it was downloading my .cfm file.
Try swapping 'inline' with 'attachment', in your Content-Disposition header.
Basically, inline will try, always varying by borwser, to open the file inside the browser. In any case what you're trying to do you should definitely use attachment. This will directly go to the user and force a download.
Related
I have been facing an issue on my code for opening PDF files. The code is:
window.open(url_pdf_file, "_blank");
The issue is:
On the same user's browser, a PDF file has been opened automatically by the browser and the user can read the PDF file on the browser, but for others PDF files the download operation has been started automatically and the browser has not been opened.
Is there a way for always opening the browser for the user?
I am trying to download an Excel file from my client using the file-saver JS library.
Currently, we hit an endpoint on the server to download the file. When it returns successfully, we use middle-ware to get the blob from the payload and then download it using FileSaver.saveAs(blob, fileName).
Previously, we used an iFrame to accomplish this.
Using the file-saver library, the source URL is blob:https://localhost:8080/...
Previously, there was no blob: text at the beginning of the URL, and it seems this text is causing the excel file to open in "Protected View".
We have the url "https://localhost:8080/*" in the list of Excel's trusted sources, and opening the file works fine using an iFrame.
Is there any way to remove the blob: prefix or make this download open regularly?
Its because of your local settings. You can follow this.
Open Excel file.
File--> Option --> Trust Center--> Trust center settings.
Trust locations--> Add "Download" folder path as trusted.
Any file open from this location is trusted by Excel hence "Enable Edit" option will not be shown. All formulas pre-applied.
I am using window.open to download a file.
window.open(urlToDownload)
The download link which I am trying to open can either be a link to a content in amazon s3 bucket or directly a link to a file in my file system.
Currently the browser is immediately downloading the content. Instead I would like the browser to show a prompt message which says either to save or open the file. My file will be in .xlsx format.
I'm trying to make it so that a file from my web server can be downloaded to an Android mobile device. I want the user to be able to press a Download button on the site, and then they will have the option to save it on there phone's sd card.
The only way I can think of doing this is by using FTP, and having the button navigate the user to ftp://username:pass#webserver/file.blah
Is there another way, using strictly HTML5 and JS?
I have tried using the download tag, but that doesn't seem to work. Instead of downloading the image it redirects them to the page with the image on it.
Link
HTML5 solution
To force downloading a file, if you are using HTML5, then you can use the download attribute by defining the anchor tag like this.
Download Link
Server-side solution
It is likely that the user's browser doesn't support the download attribute. Check this. So the other solution invloves the server-side. You can use the Content-Disposition HTTP header. Serve this as one of the headers of the HTTP response for the download route. This will force the browser to download the file as an attachment.
Content-Disposition: attachment; filename="download.png"
RFC Read section 19.5.1
I have a URL which I don't want to open up in a browser. The servlet which my URL points to is able to download the JPEG image of the rendered HTML document using html2canvas library based on specific params.
How can I download the HTML as JPEG even without rendering the HTML on the client side. Is that possible?