本文介绍了是否可以将远程文件从 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/全部/#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:

  • electron 是否能够将 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. 您在远程文件的 UI 中拥有您的表示,并且可以将这些表示拖动"到桌面.
  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 拖到文件系统上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 15:32