Skip to content

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

@jmcrthrs

Description

@jmcrthrs

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

  • I found a bug
  • 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:

if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path

What is the expected behavior?

As reported in #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions