IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
885 stars 495 forks source link

m4a files uploaded in a zip get wrong mimetype #10922

Closed jo-pol closed 3 weeks ago

jo-pol commented 1 month ago

What steps does it take to reproduce the issue?

Upload toolsfairy-audio.zip on a dataset page

dataset page

The filet gets contentType application/octet-stream

all

The file should get contentType audio/x-m4a like when uploading the individual files with chrome

Which version of Dataverse are you using?

v. 6.4 build 1609-906f874

Any related open or closed issues to this bug report?

https://github.com/gdcc/dataverse-ansible/pull/375 to show the previewer for the proper content type

Are you thinking about creating a pull request for this issue? yes

sbarbosadataverse commented 1 month ago

We tested the zip file included in this issue and are able to duplicate the bug. The system recognizes the file type once we upload the m4a file by itself.

Screen Shot 2024-10-16 at 4 24 31 PM

scolapasta commented 1 month ago

One thing that's strange is when you call the redetect API on both the one from the zipped and the one that was direct:

from zip file:

{"status":"OK","data":{"dryRun":true,"oldContentType":"application/octet-stream","newContentType":"application/octet-stream"}}

from direct: {"status":"OK","data":{"dryRun":true,"oldContentType":"audio/x-m4a","newContentType":"application/octet-stream"}

which means it would change it to be the same as the one where it didn't detect it... why would that be? and how did it correctly detect it on upload?

qqmyers commented 1 month ago

If the browser supplies a mimetype, we use it if our internal detection only gives application/octet-stream.

pdurbin commented 1 month ago

Right, here's how we document this behavior:

"Please note that it’s possible to “trick” a Dataverse installation into giving a file a content type (MIME type) of your choosing. For example, you can make a text file be treated like a video file with -F 'file=@README.txt;type=video/mpeg4', for example. If the Dataverse installation does not properly detect a file type, specifying the content type via API like this a potential workaround."

-- https://guides.dataverse.org/en/6.4/api/native-api.html#add-a-file-to-a-dataset