是否可以将远程文件从 Electron App 拖到文件系统上?

Is it possible to drag a remote file out of Electron App onto the file system?(是否可以将远程文件从 Electron App 拖到文件系统上?)
本文介绍了是否可以将远程文件从 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 拖到文件系统上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)