Example usage for com.google.common.net MediaType APPLICATION_BINARY

List of usage examples for com.google.common.net MediaType APPLICATION_BINARY

Introduction

In this page you can find the example usage for com.google.common.net MediaType APPLICATION_BINARY.

Prototype

MediaType APPLICATION_BINARY

To view the source code for com.google.common.net MediaType APPLICATION_BINARY.

Click Source Link

Document

This is a non-standard media type, but is commonly used in serving hosted binary files as it is <a href="http://code.google.com/p/browsersec/wiki/Part2#Survey_of_content_sniffing_behaviors"> known not to trigger content sniffing in current browsers</a>.

Usage

From source file:org.apache.nifi.processors.evtx.MalformedChunkHandler.java

public void handle(FlowFile original, ProcessSession processSession, String chunkName, byte[] badChunk) {
    FlowFile flowFile = processSession.create(original);
    flowFile = processSession.putAttribute(flowFile, CoreAttributes.FILENAME.key(), chunkName);
    flowFile = processSession.putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(),
            MediaType.APPLICATION_BINARY.toString());
    flowFile = processSession.write(flowFile, out -> out.write(badChunk));
    processSession.transfer(flowFile, badChunkRelationship);
}

From source file:org.onlab.stc.MonitorWebSocketServlet.java

private MediaType contentType(String uri) {
    int sep = uri.lastIndexOf(DOT);
    String ext = sep > 0 ? uri.substring(sep + 1) : null;
    return ext == null ? MediaType.APPLICATION_BINARY
            : ext.equals("html") ? MediaType.HTML_UTF_8
                    : ext.equals("js") ? MediaType.JAVASCRIPT_UTF_8
                            : ext.equals("css") ? MediaType.CSS_UTF_8 : MediaType.APPLICATION_BINARY;
}

From source file:com.github.maoo.indexer.client.WebScriptsAlfrescoClient.java

@Override
public InputStream fetchContent(String contentUrlPath) {
    HttpGet httpGet = new HttpGet(contentUrlPath);
    httpGet.addHeader("Accept", MediaType.APPLICATION_BINARY.toString());
    if (useBasicAuthentication()) {
        httpGet.addHeader("Authorization", "Basic " + Base64.encodeBase64String(
                String.format("%s:%s", username, password).getBytes(Charset.forName("UTF-8"))));
    }//from   ww  w. ja v a  2s . c om

    CloseableHttpClient httpClient = HttpClients.createDefault();
    try {
        HttpResponse response = httpClient.execute(httpGet);
        InputStream stream = response.getEntity().getContent();
        return stream;
    } catch (Exception e) {
        throw new AlfrescoDownException("Alfresco appears to be down", e);
    }
}