file-selector icon indicating copy to clipboard operation
file-selector copied to clipboard

Introduce an option to ignore a File's absolute path in an Electron environment

Open jmcrthrs opened this issue 5 years ago • 12 comments

Do you want to request a feature or report a bug?

  • [ ] I found a bug
  • [x] I want to propose a feature

What is the current behavior?

When running in a browser environment, the native File object contains no path (a path is added by toFileWithPath) When running in an Electron environment, the native File object contains an absolute path.

https://www.electronjs.org/docs/api/file-object

Electron has added a path attribute to the File interface which exposes the file's real path on filesystem.

Because of this, file-selector skips adding a path to the File object: https://github.com/react-dropzone/file-selector/blob/1e23f600ade799c378cc0a65189708f68183cec8/src/file.ts#L20

What is the expected behavior?

As reported in https://github.com/react-dropzone/file-selector/issues/10, this behaviour is expected by some users. However I would like the option to ignore the absolute path, and instead use the relative path provided by toFileWithPath

A new boolean paramter could be provided to toFileWithPath that determines if a file's path property should be ignored.

This boolean paramter would be false by default to prevent breaking changes.

We would also have to provide a new option in react-dropzone: https://github.com/react-dropzone/react-dropzone/blob/1b1177daaa51d7cc542d59f32dfd1e2956b92a55/src/index.js#L68

If this is a feature request, what is motivation or use case for changing the behavior?

I would like consistency between Browser & Electron environments. I need this because I use the file's relative path to reconstruct the file's folder structure on our server.

Other info

jmcrthrs avatar Oct 22 '20 08:10 jmcrthrs