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.
Related
I'm new to Vue.js and would like to know if there's a way to view PDF files that are stored independently from the Vue project through said Vue application.
Here's what I need:
All PDF files are stored in a folder. I'd like to provide links to access them in the application that I get from the backend server. Upon clicking the link, the PDF should open in a new tab and the URL would simply be something like
file:///C:/Users/user/Downloads/campusmap.pdf
What I have tried so far:
<a :href="fileAddress">View file</a>
When I hover over the link on my browser, It shows the right URL but clicking on it does nothing.
If I right-click to open in a new tab, it says blocked (about:blank#blocked)
Using <router-link> shows
localhost:8080/C:/Users/user/Downloads/campusmap.pdf
when hovered over it.
Is there a way to be able to just view the PDF through a link the way I want? Please note that I can't store all the PDF files in the asset or public folders.
Thanks for your help!
You can't link to a file:// protocol url from a page sourced via the http(s):// protocol - this is a security measure built in to modern browsers. Your only option is to also serve up the local files behind a web server, or run the app locally behind a file:// url.
In IE, it's quite easy to "Open in Excel" a url to a file on a network or internet location. Is the same possible in Chrome though? The file must be opened from its current location, not from a downloaded copy. So when the user saves any changes, they save to the original location. IE Tab isn't an option either, we cant install chrome extensions.
Things I've tried:
1) Web protocol: "ms-excel:ofe|u"
Open in Excel
2) ActiveX (I know it wouldnt work with Chrome, adding for completeness)
<input type=button onClick="test()" value="javascript solution">
<script type="text/javascript">
function test() {
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = true;
Excel.Workbooks.Open("//server/folder/Test.xls");
}
</script>
3) Direct link to the file:
Click<br />
This just downloads the file to the local machine and can be set to open as soon as it downloads, but changes are saved locally.
UPDATE:
I've found that trying to access a file stored in sharepoint works using method 1 above.
Open in Excel
Any reason it would work for sharepoint files but not files stored in a network location?
UPDATE:
I've found documentation for the ms-excel:ofe|u| web protocol which states that only http and https are supported.
*Bounty will only be awarded to answers to the specific question:
Is there any way to open a file in excel with chrome where the path to
the file is a local or network storage location rather than a
http/https url?
No it is not possible for security reasons. All newer browsers (and I guess even the newer implementations of IE), don't allow file access to the local system. Internet Explorer is the only browser that supports opening files from locations, that are seen and treated as local ones.
You can open files from a Webdav Server, which is probably, why you can access files from your SharePoint, so you could try mapping that provider of your network drive as a Webdav Server.
Source: https://www.codeproject.com/Questions/1180249/Open-edit-save-excel-sheet-from-browser-using-java AND
Is there an Application URL Protocol for MS Word?
You upload your excel on Google drive and people can use it from google sheets.
Browser functionality is to download the copy of file to local Computer.
You should use File server FTP server and other Protocols to actually edit file at source.
There are Web file manager software which can give you ability to save file. Try Cloud version of software etc to save file in web page and see the version history too. GitHub can have Private repository too.
I have written an application where on button click a .docx file is generated on the server and returned to client as base64 string. What I want to do now, is to let the user download the file in a directory of their choice.
To demonstrate what I mean, if I instead want to upload a file having a <input type='file'/> opens a dialog such like this
Where I can select the file. Is there any way to open this kind of dialog for a download button? I understand that the web-page doesn't receive the actual path on a clients pc for security reasons, but if you can chose an upload file, there is no reason to not chose a download path right?
No, for security reasons this is not possible.
See:
https://github.com/eligrey/FileSaver.js/issues/42
I have a JS code which should download a file and need to open that corresponding file. I'm able to download it but need a JavaScript code to open the recently downloaded file from any browser.
Answer is No.
Why :
When user download file into his local file system then downloaded file became a part of users file and as you know you can't access any file/directory from users local file system.
Alternative solution :Yes
Download file using XmlHttpRequest (AJAX) into blob object help link
Open file from saved blob object.
in above alternative solution You can also allow use to save file(download file).
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.