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

GeoJSON files marked as "Unknown"/"application/octet-stream" #8261

Closed
kaitlinnewson opened this issue Nov 30, 2021 · 4 comments · Fixed by #8262
Closed

GeoJSON files marked as "Unknown"/"application/octet-stream" #8261

kaitlinnewson opened this issue Nov 30, 2021 · 4 comments · Fixed by #8262

Comments

@kaitlinnewson
Copy link
Contributor

Hi Dataverse team,

I'm reporting this issue as I've developed a file previewer for GeoJSON files, but don't believe we can use it without being able to enable it for this specific content type, and in order to do that, GeoJSON files need to be individually identified. Hoping this is possible!

What steps does it take to reproduce the issue?

  1. Upload a GeoJSON file to Dataverse
  2. View the file type, which is "Unknown" in the UI
  3. In the API, in the files list the content type for the file is "application/octet-stream". Here's an example from the Harvard DV.

When does this issue occur?

When uploading GeoJSON files.

What happens?

After uploading a GeoJSON (.geojson) file to Dataverse, the file type displayed in the UI is "Unknown". Through the API, I can see the content type being set as "application/octet-stream". I have checked older files and also uploaded a few geojson files to the Harvard demo (v 5.8). Here's an example of a GeoJSON file in the Harvard DV.

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

All users

What did you expect to happen?

The MIME type should be "application/geo+json". I'm hoping it's possible to detect this (as opposed to it being marked as "application/json" or "text/plain").

Which version of Dataverse are you using?

5.1/5.8

@djbrooke
Copy link
Contributor

Hey @kaitlinnewson, really exciting to hear about the previewer.

If you're interested, I think a PR similar to #7502 would do the trick. If you'd be interested in making this PR, I can have someone more technical than me confirm that this is the correct path.

@pdurbin
Copy link
Member

pdurbin commented Nov 30, 2021

@kaitlinnewson hi! As a workaround, you can set the content type via API when you first upload the file. Check this out from https://guides.dataverse.org/en/5.8/api/native-api.html#add-a-file-to-a-dataset

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.

A better, longer term solution is to add .geojson to the list of file extensions Dataverse knows about. A pull request would touch these three files:

  • src/main/java/propertyFiles/MimeTypeDetectionByFileExtension.properties
  • src/main/java/propertyFiles/MimeTypeDisplay.properties
  • src/main/java/propertyFiles/MimeTypeFacets.properties

If you'd like to make a pull request, you can model it off pull request #5934 and pull request #7502.

@djbrooke
Copy link
Contributor

@pdurbin I'll take that as a confirmation... :) Thanks!

@kaitlinnewson
Copy link
Contributor Author

Thanks for your guidance @djbrooke and @pdurbin! Hopefully my PR does the trick.

Here's a sneak preview of the new previewer:

Screen Shot 2021-11-30 at 2 11 28 PM

pdurbin added a commit to kaitlinnewson/dataverse that referenced this issue Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants