uptick / react-keyed-file-browser

Folder based file browser given a flat keyed list of objects, powered by React.
MIT License
301 stars 144 forks source link

Download files #104

Closed cornelast closed 4 years ago

cornelast commented 4 years ago

Hi,

am I just really stupid or do I miss the option to download files? I can see there is a function there, but I cannot seem to find a way to get the link displayed.

scaredcat commented 4 years ago

Hi @cornelast , Please make use of the onDownloadFile prop. That function is passed to the onClick handler for the Download button in the default actionRenderer.

If you've overwritten the actionRenderer, then you should be able to implement your own download button in your custom actionRenderer that you passed in as a prop.

cornelast commented 4 years ago

Yeah, working great, thanks.

RebeccaWang0221 commented 4 years ago

Hi,

I am trying to use the package but failed to implement the download function. Would you provide a simple example of how to do this? I've read through the issues but still couldn't figure it out. Thank you so much!

scaredcat commented 4 years ago

@RebeccaWang0221

You can use the props as demonstrated in the code snippet below. Let me know if you have any issues.

<FileBrowser 
  files={myArrayOfFiles}
  onDownloadFile={arrayOfSelectedItems => { console.log('downloadFile', arrayOfSelectedItems) }}
  onDownloadFolder={arrayOfSelectedFolders => { console.log('downloadFolder', arrayOfSelectedFolders) }}
/>
RebeccaWang0221 commented 4 years ago

@scaredcat Thank you so much for your reply and help! The code is working now.