Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIME type of netCDF (.nc) files with direct upload #9884

Open
stevenferey opened this issue Sep 6, 2023 · 2 comments
Open

MIME type of netCDF (.nc) files with direct upload #9884

stevenferey opened this issue Sep 6, 2023 · 2 comments
Labels
Feature: File Upload & Handling Type: Bug a defect User Role: Depositor Creates datasets, uploads data, etc.

Comments

@stevenferey
Copy link
Contributor

entrepot.recherche.data.gouv.fr

What steps does it take to reproduce the issue?

Have direct upload enabled
Have a netCDF file with a .nc file extension

  • When does this issue occur?

A user downloads a netCDF (.nc) file with direct upload active

  • Which page(s) does it occurs on?

the dataset page

  • What happens?

Having this configuration in the MimeTypeDetectionByFileExtension.properties file: nc=application/netcdf
I expect to get this MimeType in BDD when adding a .nc file to my dataverse.
This is not the case :)

I get the MimeType "application/x-netcdf" and I can't see the previewer for this file because it is configured for the MimeType "application/netcdf"

Note that when I apply a redetect with the API, the result is OK:
{"status":"OK","data":{"dryRun":true,"oldContentType":"application/x-netcdf","newContentType":"application/netcdf"}}

  • To whom does it occur (all users, curators, superusers)?

All the users

  • What did you expect to happen?
  1. For Java and Apache, the MimeType for .nc and .cdf files appears to be "application/x-netcdf".
    Perhaps we need to adapt MimeTypeDetectionByFileExtension.properties and the previewers in order to maintain consistency?

  2. Add "application/x-netcdf" to previewers to enable it for this MimeType

Which version of Dataverse are you using?

5.14

Any related open or closed issues to this bug report?

@pdurbin
Copy link
Member

pdurbin commented Sep 6, 2023

@stevenferey just to restate what you're saying to make sure I understand...

  • When using direct upload the MIME type becomes "application/x-netcdf".
  • When not using direct upload the MIME type becomes "application/netcdf".

Is that right? Have you tested non-direct upload? There are caveats associated with direct upload: https://guides.dataverse.org/en/5.14/developers/big-data-support.html#features-that-are-disabled-if-s3-direct-upload-is-enabled

Maybe we could add more tests as part of this "test S3" issue:

In FileUtilTest we have the following...

@Test
public void testNetcdfFile() throws IOException {
    // We got madis-raob.nc from https://www.unidata.ucar.edu/software/netcdf/examples/files.html
    // and named it "madis-raob" with no file extension for this test.
    String path = "src/test/resources/netcdf/";
    String pathAndFile = path + "madis-raob";
    File file = new File(pathAndFile);
    String contentType = FileUtil.determineFileType(file, pathAndFile);
    assertEquals("application/netcdf", contentType);
}

... which asserts that the MIME type should be "application/netcdf" when the determineFileType method is used. The possible MIME types it can assign are these:

case "NetCDF":
    return "application/netcdf";
case "NetCDF-4":
    return "application/netcdf";
case "HDF5":
    return "application/x-hdf5";

Yes, as a workaround, you could add the previewer twice for both MIME types. This is already the strategy for the image previewer (for PNG, GIF, JPG, etc.).

@stevenferey
Copy link
Contributor Author

Hello Philip,

Yes that's fine, the observed behavior is :

  • When using direct upload the MIME type becomes "application/x-netcdf".

  • When not using direct upload the MIME type becomes "application/netcdf".

Yes, we will use the recommended workaround.

Thank you
Steven.

@pdurbin pdurbin added Feature: File Upload & Handling Type: Bug a defect User Role: Depositor Creates datasets, uploads data, etc. labels Oct 13, 2023
@DS-INRAE DS-INRAE moved this to 🔍 Interest in Recherche Data Gouv Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: File Upload & Handling Type: Bug a defect User Role: Depositor Creates datasets, uploads data, etc.
Projects
Status: 🔍 Interest
Development

No branches or pull requests

2 participants