@Named(value="default") @Singleton public class DefaultContentValidator extends org.sonatype.goodies.common.ComponentSupport implements ContentValidator
ContentValidator
.Constructor and Description |
---|
DefaultContentValidator(org.sonatype.nexus.mime.MimeSupport mimeSupport) |
Modifier and Type | Method and Description |
---|---|
String |
determineContentType(boolean strictContentTypeValidation,
org.sonatype.nexus.common.io.InputStreamSupplier contentSupplier,
org.sonatype.nexus.mime.MimeRulesSource mimeRulesSource,
String contentName,
String declaredContentType)
Determines or confirms the content type for the given content, or throws
InvalidContentException if it
cannot. |
public static final String NAME
@Inject public DefaultContentValidator(org.sonatype.nexus.mime.MimeSupport mimeSupport)
@Nonnull public String determineContentType(boolean strictContentTypeValidation, org.sonatype.nexus.common.io.InputStreamSupplier contentSupplier, @Nullable org.sonatype.nexus.mime.MimeRulesSource mimeRulesSource, @Nullable String contentName, @Nullable String declaredContentType) throws IOException
ContentValidator
InvalidContentException
if it
cannot.determineContentType
in interface ContentValidator
strictContentTypeValidation
- whether the check should be strict or not.contentSupplier
- the supplier of the content to determine or confirm content type.mimeRulesSource
- if non-null, mime rules source to use.contentName
- blob name, usually a file path or file name or just extension
(file extension is used to determine content type along with "magic" detection
where actual content bits are used, like file headers or magic bytes). Is
optional, but be aware that if present it improves content type detection
reliability.declaredContentType
- if non-null, the declared content type will be confirmed, if null, this method
will attempt to determine the content type.IOException
Copyright © 2008–2021 Sonatype, Inc.. All rights reserved.