Download file from server with save dialog electronjs - electron

I am developing electron app. I am looking for way in which when user clicks on button then user can download the file from server at specific location ( save dialog).
I have tried various ways but none of them worked. I am looking for code. Thanks

https://gist.github.com/8839edb51e2b11e93a25ae3bb1d83166
Here's a minimal Gist example, openable from Electron Fiddle.
The crux of the code is that you should be using the dialog.showSaveDialog API to let the user choose a path for your file, and then use your preferred JavaScript method to write the file from the server to your filesystem.
IPC is used such that the button can tell the main process (which triggers the dialog and handles the filesystem operation) to do begin its work.

A good option would be using Electron-dl (https://github.com/sindresorhus/electron-dl). They present several options according to your usage.

Related

open an excel file located on the server instead of download it MVC

I'm building a Reporting web application right now with MVC3 and I've come up to a couple problems.
My goal is to have it able to generate and view Crystal Reports, SSRS reports, and Excel documents.
Right now I'm working on the Excel segment and I'm running into more trouble than I thought I would. First off, when I link directly to the file, it either opens inside the browser or it downloads it from the server and if the user makes changes it doesn't actually save it to the true file on the server.
I've tried both linking to the file directly using Razor and a ViewModel with the path to the document as well as directing it to an action that returned a File.
I've also tried linking it to a shortcut to the actual file thinking that if I could open the shortcut it would open the file the way I wanted it to and unfortunately it didn't really open at all.
The users already have access to the files on the server through a network drive, so as of right now they can go into the server, open the excel document, edit and save it no problem. I want to duplicate this effect through a link. The program already has a file browser built, so I can browse between the files and make links to the reports.
Thanks in advance!
Since they are apparently on a network drive, you can just link to the files directly, relative to the user?
For example: a link to file://///SERVERNAME/folder/
I tested it between two computers on the network, and that seems to work. However, you still get a popup asking that you want to do with the file, open or save. (both in firefox and IE)
Note: Yes, that many slashes seem necessary, lol

Config file to change values within an app

I'm having a problem meeting a requirement for an Java app I'm developing. My client must be able to deploy the app to multiple BES servers without the need to resign the code (or have any interaction with the developers). Currently the web address of one of their BES servers is hard coded into the app but they require the ability to change this value at will prior to deployment. (it can be assumed they will administrate any BES server the app is deployed from)
I've tried attaching a text file to the project which is read by the app but this is packaged along with the app, meaning it can't be manually edited (as far as I'm aware), I've also tried having a custom property in the JAD file but this needs resigned after any change.
Am I doing any of these approaches wrong or is there a better solution I'm missing?
Also, is it possible to deploy a simple text file to a BlackBerry via the BES to a specific file location? If so I could have my app read this file which would solve the problem?
Thanks,
Implement custom attachment handler in your application.
And send email with an attached xml-config file to BlackBerry device.
User opens the received message and selects the custom menu item provided by attachment handler.
And you can parse this xml config and act accordingly.
An easier way is to use a user defined ItPolicy to provide the configuration information you need.

delphi prevent access files from TwebBrowser

I use TEmbeddedWB (internet explorer activex) in my projects.
I want to prevent people from uploading files:
ex: goto gmail.com and then attch a file: Internet explorer opens the upload file windows that allows people to access local disk.
Is there a simple way to prevent this windows from being displayed ?
Regards
It sounds like you are trying to "sandbox" your app so that your users cannot access the local file system. Perhaps you're building an app that is hosted on Citrix with multiple users, and if one of them "breaks out" of the app, they can run rampant through the file system on the server.
I don't know if there is a simple answer to this particular question, but I recommend that you look at the total problem before trying to solve the individual issues, as you may find that there are just too many. For instance, in the browser ActiveX, you can also "view source". That probably opens Notepad on the server. From there, you can run rampant. Do you have CHM help? From the help window, you can also access the "open file" dialog. Do you allow the user to open/save files through your regular menus? Same issue. How about hyperlinks? If your About box has a hyperlink, that's an easy way to pop open a browser. Can the user enter an address for browsing in your embedded ActiveX? If so, can they enter things like: C:\WINDOWS\system32\cmd.exe
You could decouple the navigation, do it yourself, sanitize the HTML then display the sanitized version. Unfortunately you would have to do this for ALL resources and would need to handle the numerous JavaScript libraries. For basic HTML, look for <input type="file". This would at least catch the basic usage, but not the more advanced usage.
A simpler solution might be to limit what URL's the browser can navigate too and only allow URL's you know are safe.
Assuming you don't want them to browse the local machine, if you solve the "open file" problem the same issue exists if you have a "save file" dialog. You may have to close those loops by replacing the browser popup menu with one that does not have any "Save x As..." options.

How Can I Automatically Execute A Link In Internet Explorer

I am trying to create an application to print documents over the web. I have created my document, and made a web page with a meta refresh tag, along the lines of this:
<meta http-equiv="refresh" content="3;http://example.com/download.epl2" />
I specify that the document has a content-type of application/x-epl2, and I have associated .epl2 files on my computer with a program that silently sends them to the printer.
I have put the website into my trusted sites zone.
Currently Internet Explorer pops up the "Open, Save, Cancel" dialog box with no option to automatically open the file.
Is there a setting in IE6/7/8 that I can use to have IE just open the file without prompting?
EDIT
The actual content of the file will differ based on the job, but essentially it is text that follows the Eltron Programming Language.
EDIT
I have accomplished this in both Chrome and Firefox by choosing "Automatically Open Files Of This Type From Now On"
EDIT
The machines this program will be used on will effectively be kiosks that are limited to only accessing my website from their web browsers, so I'm not worried about rogue websites sending documents to my printers.
EDIT
I am using PHP to generate the documents and HTML on the server side, though I expect the solution to be language agnostic.
I would expect that not to be possible, because then you could stumble onto a site that automatically loads and prints a 5000 page document or something, which would not be good.
If you always had a secret desire to develop a custom URL protocol (I know I do), this might be a good excuse to do it. ;-)
http://msdn.microsoft.com/en-us/library/aa767914%28VS.85%29.aspx
There are 1-2 prompts when opening such a link for the first time in IE, but you can choose to automatically open them after that.
I would use javascript to make this happen.
Javascript Window Open
EDIT
Since you have control of the windows box you could use an automate script process to interact with the print window.
autoit3: ControlClick
Write a small utility program that does nothing but send the file passed to it on the command-line to the default system printer.
Then, edit the registry under HKEY_CLASSES_ROOT to associate this program with the .epl2 filetype.
I don't have time to investigate it for You, but there were lots of exploits that could be helpful. Using ie6 without certain fixes seems helpful.
Also there should be an option called "Automatic prompting for file downloads". I use Linux nowadays so I can't chceck if it helps. I found it in some docs.
I'm on a Mac at the moment, but if this is possible in IE I would imagine this page holds the answer to it (or at least hints at it) http://support.microsoft.com/kb/883255
I believe what you're looking for is a setting in Windows, not IE:
Microsoft Support: Not Prompted to Specify Download Folder for File
Try using an older version of IE. Security was looser in the older versions and since it's a non-issue, this could be the quickest solution.

Download a static file in Silverlight 3 without using SaveFileDialog

I have a Silverlight 3 app that that will let users download PDF files of static content. The problem is that the SaveFileDialog in Silverlight 3 does not allow you to specify the default filename that appears in the dialog box. This means that users have to type the name themselves and this is confusing for them since they are accustomed to a "simple" save dialog which only asks them to either Save or Cancel. All users are using IE7 or IE8.
I've tried to find a solution by the following methods:
Open the file new window using HtmlPage.Window.Navigate hoping to prompt a download (which obviously fails since it opens the file in a new window)
Using the SaveFileDialog (which we don't want to use for the aforementioned reason)
How can a file be downloaded in Silverlight such that a user-initiated save dialog only gives users the option to Save/Cancel instead of prompting to type a file name?
This is a well-known issue with SL3 SaveFileDialog. Unfortunately, there is currently nothing on the horizon that says it will get fixed other than someone at MSFT saying something to the effect of "if we have some time, we'll fix it for SL4". There is a bit of a riot by developers over at http://forums.silverlight.net/forums/p/117702/265216.aspx.
Did you try setting the default extension on the SaveFileDialog? See MSDN documentation: http://msdn.microsoft.com/en-us/library/system.windows.controls.savefiledialog.defaultext%28VS.95%29.aspx

Resources