是否可以将远程文件从Electron App拖到文件系统上? [英] Is it possible to drag a remote file out of Electron App onto the file system?

查看:77
本文介绍了是否可以将远程文件从Electron App拖到文件系统上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试Electron应用程序的文件系统拖放功能,并且在使所有内容都可以与本地文件一起使用方面没有任何问题。我在文档中没有看到任何内容,所以我想看看是否有人知道这是否可行。 我想使用Electron中的拖出功能将远程文件拖到应用程序外部并拖到文件系统上。

I have been playing around with the file system drag and drop functionality of Electron apps and haven't had any issues getting everything to work with local files. I have not come across anything in the documentation, so I'd like to see if anyone knows if this is possible. I'd like to use the drag-out feature in Electron to drag a remote file outside of the app and onto the file system.

具体示例:
我正在处理的程序是一个远程文件管理工具-与Dropbox类似。我想将代表远程文件的dom元素拖到Finder(或Windows资源管理器)窗口中,并让Electron将文件下载到该位置。

Specific example: The program I am working on is a remote file management tool - similar to dropbox. I'd like to drag the dom element representing the remote file to a Finder (or Windows Explorer) window and have Electron download the file to that location.

我能够只要文件按照Electron文档存储在本地,就可以使它正常工作。
http://electron.atom。 io / docs / all /#dragging-files-out-of-the-window

I am able to get this to work as long as the file is stored locally following the Electron documentation. http://electron.atom.io/docs/all/#dragging-files-out-of-the-window

我可以设想两种可能的解决方案:

I can envision two possible solutions:


  • 电子是否有能力将DownloadItem或URL传递给 startDrag事件(如上面的链接中所述)?

  • 是否可以侦听某种已丢弃消息并获取放置了dom元素的本地文件系统路径?例如,/ Users / {proile} / Desktop?我可以使用现有的下载方法将文件下载到该特定路径。

任何关于如何实现目标的想法?非常感谢您抽出宝贵的时间。

Any thoughts on how I can accomplish my goal? Thanks so much for your time.

推荐答案

我还没有看到此类功能的任何示例-但它没有似乎很难将其拼凑在一起(著名的遗言……)

I haven't seen any examples of this sort of functionality – but it doesn't seem like it would be hard to cobble it together (famous last words...)


  1. 您在遥控器的用户界面中拥有了自己的表示形式文件,并将这些文件拖到桌面上。

  2. 当用户拖动这些表示形式之一时,您会捕获目标位置

  3. 您开始下载相关文件并将其保存到目标位置

至少这是我开始使用的方式。
有很多与电子有关的库都在处理下载内容(例如 electron-dl )。如果您可以使用此功能,请报告并共享详细信息。

At least that is how I would start to approach it. There are various electron related libs dealing with downloads (e.g. electron-dl). If you get this working, report back and share the details.

这篇关于是否可以将远程文件从Electron App拖到文件系统上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆