uptick / react-keyed-file-browser

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

Files show as folders when no size is provided #45

Closed YassienW closed 5 years ago

YassienW commented 5 years ago

When providing an array of files that only have keys, all the files show as folders. Is this intended behavior or is there a way to make them show as files without providing the size?

dguayrobotiq commented 5 years ago

@YassienW Have you found a workaround for this? This is really annoying when working with file that may have a size of 0 (i.e. file created with touch)

YassienW commented 5 years ago

@dguayrobotiq Well, if you can certainly know it will be a file just set the size to 1 using a condition. Sadly there is no way to easily hide the size column. A possible fix would be to make it so that when size is not null then it's a file; this way the size variable can be used to control if it's a file or folder I would submit a PR with those changes but it seems like the project is sleeping. If the project goes unmaintained i will implement this in my own fork

dguayrobotiq commented 5 years ago

@YassienW That's what I'm doing now but I don't like faking the size of a file to 1. Thanks for replying !

YassienW commented 5 years ago

@dguayrobotiq I will let you know if i implement this in my fork

jlo-1 commented 5 years ago

Hi @YassienW,

We primarily use this package with S3, which appears to distinguish folder from files by appending a trailing slash. Will look into updating this package to potentially work in a similar fashion in the coming days.

File size of 1 sounds yuck.. :)

Thanks for reporting!

dguayrobotiq commented 5 years ago

@jlo-1 We are working with S3 as well but even if the path doesn't have a trailing slash, if the size is 0, the file is displayed as a folder.

jarekwg commented 5 years ago

So changing RKFB to use trailing slashes as its criterion for what is considered a folder (rather than have it looking at file size) will fix this, yes?

Or are you saying S3 displays 0-size files as folders?

jlo-1 commented 5 years ago

Fixed and merged in https://github.com/uptick/react-keyed-file-browser/pull/53. FolderRenderer will now be used if a file key ends with a trailing slash, and FileRenderer will be used otherwise.