Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

webContents.startDrag() for dragging and dropping remote files out of Electron into local filesystem #11691

Open
eladnava opened this issue Jan 22, 2018 · 14 comments

Comments

@eladnava
Copy link

eladnava commented Jan 22, 2018

  • Electron version: 1.7.10
  • Operating system: Mac OS X Sierra

Hey guys! I love what you've done with Electron. Keep it up! 馃挴

I'm building a remote file explorer in Electron. I would like to have the ability to drag files out of Electron into the Mac OS X Finder. This can be achieved using webContents.startDrag() but this only works for local files that already exist. Since my file explorer manages remote files, I do not have a local file path to pass to webContents.startDrag() yet.

Is there any way to implement this kind of remote file drag-drop behavior with Electron? I was thinking of listening to the 'drop' event, intercepting the path, and downloading the files to this path via Node.js code.

However, Electron never seems to call any event after the webContents.startDrag() file has been successfully moved. Any ideas?

This has been asked on StackOverflow as well with no solution as of today:
https://stackoverflow.com/questions/43209509/is-it-possible-to-drag-a-remote-file-out-of-electron-app-onto-the-file-system?rq=1

@welcome
Copy link

welcome bot commented Jan 22, 2018

馃憢 Thanks for opening your first issue here! If you're reporting a 馃悶 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@eladnava eladnava changed the title webContents.startDrag() for dragging remote files out of Electron webContents.startDrag() for dragging and dropping remote files out of Electron into local filesystem Jan 22, 2018
@sofianguy
Copy link
Member

Thanks for reaching out!

Because we treat our issues list as the team's backlog, we close issues that are questions since they don't represent a task needing to be completed. For most questions about Electron there are a lot of options.
Check out the Electron community. There are also a bunch of helpful people in this community forum that should be willing to point you in the right direction.

@eladnava
Copy link
Author

Hi @sofianguy,
Thanks for your response!

This is actually a feature request. I was asking it in a question format because I was also considering a workaround as a possibility, instead of modifying core Electron code to add this as a feature.

I'm sure a lot of developers will find this feature vital. If you could reopen this, that would be much appreciated. 馃憤

@frank0r
Copy link

frank0r commented Mar 17, 2018

is this feature under developing? I have same needs on this, my problem can be solved by just giving a filePath param in the dragging element's dragend event.

@frank0r
Copy link

frank0r commented Mar 17, 2018

the filePath param's value is the dropped folder's path

@carsonxu
Copy link

@eladnava It this question resolved?

@eladnava
Copy link
Author

eladnava commented Aug 11, 2018

@carsonxu Unfortunately not. There is still no way to drag "theoretical" files out of Electron. They have to first exist on the filesystem as startDrag must accept a local file path. There is also no event we can listen to in order to intercept the drag-n-drop out of Electron either.

@kurtisauc3
Copy link

any updates on this? maybe we can register a custom file protocol?

@whyboris
Copy link

Turns out it works 馃帀 thanks to #6333 (comment)
See documentation: https://www.electronjs.org/docs/tutorial/native-file-drag-drop#native-file-drag--drop

I tested just now - works in my app (dragging a video file out of my app into Vegas video editor or onto the desktop): whyboris/Video-Hub-App#519 (comment)

@fralonra
Copy link

Turns out it works 馃帀 thanks to #6333 (comment)
See documentation: https://www.electronjs.org/docs/tutorial/native-file-drag-drop#native-file-drag--drop

I tested just now - works in my app (dragging a video file out of my app into Vegas video editor or onto the desktop): whyboris/Video-Hub-App#519 (comment)

Does your code run in Mac OS?
I've had a similar use case which @eladnava had: downloading the remote file into local system after dragging out of an Electron app.
I have tried the code in the documentation, but it did not work in Mac.

@whyboris
Copy link

I just checked on Mac and got this error in my app:
image
It's possible that I just need to fix something and it will work 馃し
At the very least - you could try the code I refer to (it's only a few lines) and it works on Windows 馃憤

@fralonra
Copy link

I just checked on Mac and got this error in my app:
image
It's possible that I just need to fix something and it will work
At the very least - you could try the code I refer to (it's only a few lines) and it works on Windows

Hi, the error you mentioned above is due to the path passed to icon lead to a wrong place in Mac.
In my project, I should pass a relative path according to my electron entry file.

@jaime-rivas
Copy link

Hi everyone! @eladnava, @fralonra

We have a similar use case where we'd love to drag out remote files (not yet downloaded). For now, we've been downloading them manually to Electron and then using the drag and drop functionality. Since the last message is from a year ago, I'm wondering if any Electron updates might make this use case possible. Cheers to everyone on the Electron community for the great work. Thank you!

@warpdesign
Copy link
Contributor

I am also having the same problem: I am working on a file manager than can browse zip archives, so when dropping files from the archive to native apps they don't exist yet.

The suggested solution creates files before the drag&drop is initiated: this won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants