問題描述
我一直在嘗試使用 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...)
- 您在遠程文件的 UI 中擁有您的表示,并且可以將這些表示拖動"到桌面.
- 當用戶拖動其中一種表示時,您會捕捉到目標目的地
- 您開始下載相關文件并將其保存到目標位置
至少我會這樣開始處理它.有各種與電子相關的庫處理下載(例如 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 拖到文件系統上?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!