Examples of MimeTypes


Examples of com.amazonaws.services.s3.internal.Mimetypes

        if(metadata == null) {
            metadata = new ObjectMetadata();
        }

        if(request.getFile() != null) {
            Mimetypes mimetypes = Mimetypes.getInstance();
            metadata.setContentType(mimetypes.getMimetype(request.getFile()));
        }

        // If we generated a symmetric key to encrypt the data, store it in the object metadata.
        if(keyBytesToStoreInMetadata != null) {
            keyBytesToStoreInMetadata = Base64.encodeBase64(keyBytesToStoreInMetadata);
View Full Code Here

Examples of com.amazonaws.services.s3.internal.Mimetypes

        ObjectMetadata metadata = request.getMetadata();
        if (metadata == null) metadata = new ObjectMetadata();

        if (request.getFile() != null) {
            Mimetypes mimetypes = Mimetypes.getInstance();
            metadata.setContentType(mimetypes.getMimetype(request.getFile()));
        }

        updateMetadata(metadata, keyBytesToStoreInMetadata, symmetricCipher, materialsDescription);
        request.setMetadata( metadata );
    }
View Full Code Here

Examples of org.apache.maven.archiva.webdav.util.MimeTypes

{
    public void testArchivaTypes()
        throws Exception
    {
        lookup( MimeTypes.class );
        MimeTypes mimeTypes = (MimeTypes) lookup( MimeTypes.class );
        assertNotNull( mimeTypes );

        // Test for some added types.
        assertEquals( "sha1", "text/plain", mimeTypes.getMimeType( "foo.sha1" ) );
        assertEquals( "md5", "text/plain", mimeTypes.getMimeType( "foo.md5" ) );
        assertEquals( "pgp", "application/pgp-encrypted", mimeTypes.getMimeType( "foo.pgp" ) );
        assertEquals( "jar", "application/java-archive", mimeTypes.getMimeType( "foo.jar" ) );
        assertEquals( "Default", "application/octet-stream", mimeTypes.getMimeType(".SomeUnknownExtension"));
    }
View Full Code Here

Examples of org.apache.maven.archiva.webdav.util.MimeTypes

{
    public void testArchivaTypes()
        throws Exception
    {
        lookup( MimeTypes.class );
        MimeTypes mimeTypes = (MimeTypes) lookup( MimeTypes.class );
        assertNotNull( mimeTypes );

        // Test for some added types.
        assertEquals( "sha1", "text/plain", mimeTypes.getMimeType( "foo.sha1" ) );
        assertEquals( "md5", "text/plain", mimeTypes.getMimeType( "foo.md5" ) );
        assertEquals( "pgp", "application/pgp-encrypted", mimeTypes.getMimeType( "foo.pgp" ) );
        assertEquals( "jar", "application/java-archive", mimeTypes.getMimeType( "foo.jar" ) );
        assertEquals( "Default", "application/octet-stream", mimeTypes.getMimeType(".SomeUnknownExtension"));
    }
View Full Code Here

Examples of org.apache.nutch.util.mime.MimeTypes

    // set headers
    headers.set(Response.CONTENT_LENGTH, new Long(size).toString());
    headers.set(Response.LAST_MODIFIED, this.file.httpDateFormat.toString(f
        .lastModified()));
    MimeTypes mimeTypes = MimeTypes.get(conf.get("mime.types.file"));
    MimeType mimeType = mimeTypes.getMimeType(f);
    String mimeTypeString = mimeType != null ? mimeType.getName() : "";
    headers.set(Response.CONTENT_TYPE, mimeTypeString);

    // response code
    this.code = 200; // http OK
View Full Code Here

Examples of org.apache.oodt.cas.filemgr.structs.mime.MimeTypes

     */
    public static void main(String[] args) throws DataTransferException,
            IOException, URISyntaxException {
        String usage = "LocalFileTransfer --productName <name> --productRepo <repo> [--dir <dirRef>] [--files <origRef 1>...<origRef N>]\n";

        MimeTypes mimeTypeRepo = MimeTypes
                .buildRepository(System
                        .getProperty("org.apache.oodt.cas.filemgr.mime.type.repository"));

        String productName = null;
        String productRepo = null;
        String transferType = null;
        Reference dirReference = null;

        List<Reference> fileReferences = null;

        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("--dir")) {
                transferType = "dir";
                dirReference = new Reference();
                dirReference.setOrigReference(new File(new URI(args[++i]))
                        .toURI().toString());
                LOG.log(Level.FINER,
                        "LocalFileTransfer.main: Generated orig reference: "
                                + dirReference.getOrigReference());
            } else if (args[i].equals("--files")) {
                transferType = "files";
                fileReferences = new Vector<Reference>();
                for (int j = i + 1; j < args.length; j++) {
                    LOG.log(Level.FINER,
                            "LocalFileTransfer.main: Adding file ref: "
                                    + args[j]);
                    fileReferences.add(new Reference(args[j], null, new File(
                            args[j]).length(), mimeTypeRepo
                            .getMimeType(args[j])));
                }
            } else if (args[i].equals("--productName")) {
                productName = args[++i];
            } else if (args[i].equals("--productRepo")) {
View Full Code Here

Examples of org.apache.tika.mime.MimeTypes

        return Normalizer.normalize(text, Normalizer.Form.NFC);
    }

    private String extractTextWithTika(byte[] textBytes, Metadata metadata) throws TikaException, SAXException, IOException {
        AutoDetectParser parser = new AutoDetectParser(new MimeTypes());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(baos, "UTF-8");
        ContentHandler handler = new BodyContentHandler(writer);
        ParseContext context = new ParseContext();
        context.set(PDFParserConfig.class, new LumifyParserConfig());
View Full Code Here

Examples of org.apache.tika.mime.MimeTypes

     * @return MIME type of the document
     * @throws IOException if the document stream could not be read
     */
    private MimeType getMimeType(InputStream stream, Metadata metadata)
            throws IOException {
        MimeTypes types = config.getMimeRepository();

        // Get type based on magic prefix
        stream.mark(types.getMinLength());
        try {
            byte[] prefix = getPrefix(stream, types.getMinLength());
            MimeType type = types.getMimeType(prefix);
            if (type != null) {
                return type;
            }
        } finally {
            stream.reset();
        }

        // Get type based on resourceName hint (if available)
        String resourceName = metadata.get(Metadata.RESOURCE_NAME_KEY);
        if (resourceName != null) {
            MimeType type = types.getMimeType(resourceName);
            if (type != null) {
                return type;
            }
        }

        // Get type based on metadata hint (if available)
        String typename = metadata.get(Metadata.CONTENT_TYPE);
        if (typename != null) {
            try {
                return types.forName(typename);
            } catch (MimeTypeException e) {
                // Malformed type name, ignore
            }
        }

        // Finally, use the default type if no matches found
        try {
            return types.forName(MimeTypes.DEFAULT);
        } catch (MimeTypeException e) {
            // Should never happen
            return null;
        }
    }
View Full Code Here

Examples of org.apache.tika.mime.MimeTypes

  private static final Logger LOG = LoggerFactory.getLogger(MimeUtil.class.getName());

  public MimeUtil(Configuration conf) {
    tika = new Tika();
    ObjectCache objectCache = ObjectCache.get(conf);
    MimeTypes mimeTypez = (MimeTypes) objectCache.getObject(MimeTypes.class
        .getName());
    if (mimeTypez == null) {
      try {
          String customMimeTypeFile = conf.get("mime.types.file");
          if (customMimeTypeFile!=null && customMimeTypeFile.equals("")==false){
View Full Code Here

Examples of org.apache.tika.mime.MimeTypes

             d.detect(tis, new Metadata())
       );
    }
   
    public void testTruncatedFiles() throws Exception {
        MimeTypes mimeTypes = MimeTypesFactory.create("tika-mimetypes.xml");
        ContainerAwareDetector detector = new ContainerAwareDetector(mimeTypes);
       
        // First up a truncated OOXML (zip) file
        InputStream input = getTestDoc("testEXCEL.xlsx");
        byte [] buffer = new byte[300];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.