Default Mime Type changed and I can't figure out how to fix it


#1

I’ve been running Sonatype Nexus Repository Manager version 3.12 to manage built artifacts. When the artifacts are uploaded to the Nexus, they are set the mime type of application/octet-stream. this is good and what I expected.

I upgrade my nexus to 3.16, now all my artifacts are being uploaded as mime type text/plain. THis makes it VERY hard to download the files. There is no WEB_INF directory, so the documentation to set mime types is invalid (as outlined here: Overriding or changing default MIME types for artifact downloads – Sonatype Support)

How do I set up version 3.16 to default to application/octet-stream like the version 3.12 did by default?

Also, the API changed without a major version update which BROKE many of my integrations!


#2

What method are you using to upload the files? Can you provide an example?

Rich


#3

I follow the instructions on this page:

Using the CURL method, there is no documentation to specify the mime type.

Using the REST, the swagger doesn’t specify a parameter to specify the mime type

And if I upload through the UI, it divines the mime type automatically. There isn’t a way to specify a mime type.


#4

The thing that bothers me the most is that the default USED to be “application/octet-stream”, but now it’s text/plain, and there’s no way of specifying it or changing it through the UI. I am going to have to go into the raw blobstores on the disk and modify the properties file manually to get them to be fixed.

Usually fundamental changes like this aren’t made on a minor update. these types of changes are major-release level changes.


#5

For curl upload via PUT request you should specify the content-type header:

curl -v -u admin:admin123 -H "Content-Type: application/octet-stream" --upload-file some.file http://localhost:8081/repository/raw-hosted/org/foo/some.file

For REST API the content type would be determined during the upload. What type of file is this, and what file extension does it have?


#6

It’s a proprietary binary format file.

why did the default mime type change?! and why isn’t there a way to specify custom file extensions and mime types in Nexus3?


#7

Specifying -H “Content-Type: application/octet-stream” doesn’t set the content type. It’s still text/plain.


#8

Can 3.16 be downgraded back to 3.12? I want my previous functionality back


#9

I don’t know what (if anything) changed, I need a reproduce case. What is the file extension being used in the REST API upload?.


#10

It’s a proprietary extension and binary format that’s not going to be in any list. The extension is .2gig, and the file is a firmware load for an embedded linux device.

however, it does the exact same thing to .bin files. I have a binary .bin file that in Nexus 3.12 uploads as a “application/octet-stream”, but the exact same file (same sha1sum) uploads as “text/plain” in 3.16.

This has cost me an entire day. I’m going to attempt to roll back to 3.12. I’ll live with the security flaw if it means the system uploads files and detects the content type properly. I can’t believe there isn’t a way to specify the content type for unknown file extensions.


#11

An update… I was able to reproduce this, and I have opened an issue: https://issues.sonatype.org/browse/NEXUS-20284


#12

Can’t roll back from 3.16 to 3.12 because the database has been updated somehow. When starting, I get about 300 lines of exceptions trying to open sonatype-work/nexus3/db/componenet

2019-06-19 08:55:25,103-0600 ERROR [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusContextListener - Failed to start nexus
com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage ‘/opt/sonatype-work/nexus3/db/component’ with mode=rw
DB name=“component”

being that nexus is supposed to be an artifact repository manager, is there any way to add custom file extensions and mime types? if not, that seems like a major oversight.


#13

You can’t ever downgrade an instance to an older version, don’t try to do this.

The only way to go back to 3.12.0 would be to restore from a backup taken while that version was running.


#14

So, there’s no way to configure content types for unknown extensions?


#15

There is a hack you could try… it worked here. Open up the “nexus-3.16.2-01/system/org/sonatype/nexus/nexus-mime/3.16.2-01/nexus-mime-3.16.2-01.jar” file, and edit the “builtin-mimetypes.properties” file. Add a line like this into it:

xyz = application/octet-stream

The above sets the download mime type for extension “xyz”.


#16

I updated the properties file, repackaged the jar and copied it into place, restarted Nexus. However uploads still going in as “text/plain”


#17

What file extension is being used in your uploads?


#18

I have two:

  • bin
  • 2gig