In my Electron application I store links to local file paths. Now I would like the user to be able of opening such links using whatever application the operating system is configured for (or the usual "open with" dialog).
Is this possible?
Thanks
Found a list of possible solutions here:
https://stackoverflow.com/a/33425619/2110299
Of these, the most relevant seems to me the shell module plugin:
https://electron.atom.io/docs/api/shell/
Which provides following API:
shell.openItem(fullPath)
Open the given file in the desktop’s default manner.
Returns Boolean - Whether the item was successfully opened.
Related
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.
I am trying to create a simple electron app, that opens Google office files from Google Drive, reads the link file and creates a new window containing that google doc page.
I can make it work, if I edit info.plist after building with electron-builder to make the app accept the file extensions '.gdoc, .gsheets and .gslides'.
Is there a smarter way that doesn't involve manually editing info.plist?
Electron-builder is supposed to be able to do that through specifying the FileAssociation. I've read of various issues with this but haven't needed it myself yet– if it works for you, please report back.
There is also the Windows only electron-regedit node module:
"File associations, file icons & open with... for electron apps
This module allows you to register your app in the windows registry,
manipulate context menus & handle native open, edit, print, preview
actions ect."
However for Google drive you might be looking at registering a protocol and url scheme. There is support for that electron-packager
protocol
Array of Strings
The URL protocol scheme(s) to associate the app with. For example,
specifying myapp would cause URLs such as myapp://path to be opened
with the app. Maps to the CFBundleURLSchemes metadata property. This
option requires a corresponding protocol-name option to be specified.
protocol-name
Array of Strings
The descriptive name(s) of the URL protocol scheme(s) specified via
the protocol option. Maps to the CFBundleURLName metadata property.
We are doing webdevelopment with Zope.
The web-editor is just horrible. No syntax highlighting, no in-text-tabs, nothing you can work with.
I installed Zope External Editor. It is now possible that I click the "use external editor" button on every element and it creates a temporary file and opens it in Notepad++, awesome.
But one important thing fail: it doesn't save back to Zope when I save the file. I still have to copy the code back to Zope manually.
I also searched for syntax highlighting extension for chrome/firefox at least to highlight the code (but I prefer Notepad++ with upload-on-save).
Can someone help me with that?
Did you also download the ExternalEditor Helper application?
Your browser should open the helper application, which will then open the editor (which you can specify in the configuration, see last point below). This is important because the helper application is responsible for sending changes back to Zope, which it does by keeping an open WebDAV session while you are editing.
You should download the latest helper app here: http://plone.org/products/zope-externaleditor-client
From that page:
Under Windows: Install the windows binary executable.
Open your page in your web browser and click on the link 'edit with external application'
Associate the file with Zope External Editor and make it permanent (first time only)
The file is opened in the editor defined in windows registry with certain editors, a message will ask whether the edition is terminated or not;
keep it until you closed you file and say yes.
If you want to change your default editor for certain content types , or if you want to add proxy parameters, open Zope External Edit in your program files menu and change your local user configuration.
The best option is to not develop Zope applications through-the-web anymore.
Use proper python packages, and you'll get to use your favourite tools without difficult integration with the server.
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.
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