question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MIME type detection working for files, but not files within a dragged folder (Firefox)

See original GitHub issue

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 dragging a folder to the dropzone, the MIME types for audio files inside the folder are unset.

When I click the dropzone and choose the audio files through the file browser, the MIME types are correctly set.

I realise there are bugs about MIME type support for different browser/OS platforms. However, MIME type detection of audio files appears to work when a file/files is/are selected, but not folders.

If the current behavior is a bug, please provide the steps to reproduce. I tried using the codesandbox.io editor but found no way to share the code once I’d written it, so instead here is the simple example:

import React, {useCallback} from "react";
import { useDropzone } from "react-dropzone";

export default function App(props) {
  const onDrop = useCallback(acceptedFiles => {
    acceptedFiles.forEach(file => {
      console.log(file.type);
    });
  }, [])
  const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop })

  return (
    <div {...getRootProps()}>
      <input {...getInputProps()} />
      {
        isDragActive ?
          <p>Drop the files here ...</p> :
          <p>Drag 'n' drop some files here, or click to select files</p>
      }
    </div>
  )
}

Here’s an empty audio file inside a folder:

current-art.zip

  1. Visit the page.
  2. Click the dropzone text and choose the audio file.
  3. In the console, you should get the text audio/mpeg (it’s an MP3 file).

Now…

  1. Drag the current-art folder to the dropzone.
  2. In the console, you should get the text image/jpeg for the sibling image, but then <empty string> for the same music file.

What is the expected behavior? MIME type detection should work the same for dragging a folder as choosing a file. In the second example above, the same MIME type should be output.

Please mention other relevant information such as the browser version, Operating System and react-dropzone version. Firefox 73.0.1 Ubuntu 16.04.1 react-dropzone 10.2.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
gurkacommented, Oct 26, 2021

Looks like there already is a Firefox bug ticket for this https://bugzilla.mozilla.org/show_bug.cgi?id=1424689

0reactions
haywirezcommented, Aug 13, 2022

Also the case for Chrome 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML5 drag and drop folder detection in firefox. Is it even ...
I check whether the dragged item has no type and no size as below and in most cases it is working as expected....
Read more >
Firefox reports wrong pdf mime type - Mozilla Support
Trying to upload pdf files from Firefox, pdf files get rejected as wrong file type, works in all other browsers. ? Thanks for...
Read more >
react-dropzone
Simple React hook to create a HTML5-compliant drag'n'drop zone for files. ... Install it from npm and include it in your React build...
Read more >
Onedrive in Browser Does Not 'Drop' - Drag Works.
When I drag file over folders I the folder is hightight (box around it) ... After testing in different browsers, we find that...
Read more >
The File System Access API: simplifying access to local files
If permission isn't granted, createWritable() throws a DOMException , and the app will not be able to write to the file. In the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found