fix(drag): Drag and drop files with illegial path characters

This commit is contained in:
Ben Gotow 2016-01-12 13:51:26 -08:00
parent 8f45633fea
commit 5a12dde49c

View file

@ -65,9 +65,11 @@ class AttachmentComponent extends React.Component
<RetinaImg name="icon-attachment-download.png" mode={RetinaImg.Mode.ContentPreserve} />
_onDragStart: (event) =>
path = FileDownloadStore.pathForFile(@props.file)
if fs.existsSync(path)
DownloadURL = "#{@props.file.contentType}:#{@props.file.displayName()}:file://#{path}"
filePath = FileDownloadStore.pathForFile(@props.file)
if fs.existsSync(filePath)
# Note: From trial and error, it appears that the second param /MUST/ be the
# same as the last component of the filePath URL, or the download fails.
DownloadURL = "#{@props.file.contentType}:#{path.basename(filePath)}:file://#{filePath}"
event.dataTransfer.setData("DownloadURL", DownloadURL)
event.dataTransfer.setData("text/nylas-file-url", DownloadURL)
else