feross/drag-drop

say i want the directory?

okdistribute opened this issue · 9 comments

instead of the entire file list.

Try dragging a folder on, it will expand the directory into a file list. It'd be nice if I could tell it to not recurse through the folder and instead just give me the directory path that they dropped

Could you elaborate on your issue.
Although I am not the author of this repo, I may be able to help.

@Karissa You can't really "get the directory" for permission reasons. All you can do is get all the files within the directory. The browser returns these as a list.

just give me the directory path that they dropped

Do you mean that you don't want subfolders? You can try to ignore those by inspecting file.fullPath on each file object and ignoring subfolders.

@Karissa I think the best solution is to filter out the files you don't want by looking at their paths. This package just normalizes what the browsers give it, and that's a complete list of files in the folder that's dropped.

I was able to get what I wanted by just using drag-and-drop-files module.

On Friday, January 8, 2016, Feross Aboukhadijeh notifications@github.com
wrote:

Closed #9 #9.


Reply to this email directly or view it on GitHub
#9 (comment).

Karissa McKelvey
http://karissa.github.io/

Dropping a dirctory on OSX gives an empty list of folder :(. The drag-and-drop-files module gives the right result : an absolute path. This would be great to get the directory

@gabrielstuff What browser are you using? Only Chrome supports dropping directories. Firefox and Safari don't support directories, so what's the point of getting the directory name if you can't use any of the files inside?

@feross in an electron app, for example, I wanted just the path. drag-and-drop-files solved my problem.

@feross, even if firefox is pretty slow to integrate it, it certainly soon be possible. See https://bugzilla.mozilla.org/show_bug.cgi?id=1164310
For sure Chrome user can do it : https://html5-demos.appspot.com/static/dnd/all_types_of_import.html and when Apple will decide to make it possible with Safari this also will be useful.
In NW.js and Electron it is not a question, the HTML5 File API is fully supported and using webkitEntries and the webkit API : var items = e.dataTransfer.items;

Ok, this commit gabrielstuff@2f5620d adds a directories array in cb return.
I'm not sure it is the good way to approach the problem. I'm only returning the main directory dropped not each directory which are walked to retrieve the files.