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!
What method are you using to upload the files? Can you provide an example?
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.
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.
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?
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?
Specifying -H “Content-Type: application/octet-stream” doesn’t set the content type. It’s still text/plain.
Can 3.16 be downgraded back to 3.12? I want my previous functionality back
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?.
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.
An update… I was able to reproduce this, and I have opened an issue: https://issues.sonatype.org/browse/NEXUS-20284
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
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.
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.
So, there’s no way to configure content types for unknown extensions?
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”.
I updated the properties file, repackaged the jar and copied it into place, restarted Nexus. However uploads still going in as “text/plain”
What file extension is being used in your uploads?
Hi I tried this and was able to download my bin file
bin = application/octet-stream,application/x-msdownload
- I restarted nexus after updating mime-type properties file
- upload new file, the file uploaded previously remains as type:text