Example usage for javax.mail.internet ContentDisposition getDisposition

List of usage examples for javax.mail.internet ContentDisposition getDisposition

Introduction

In this page you can find the example usage for javax.mail.internet ContentDisposition getDisposition.

Prototype

public String getDisposition() 

Source Link

Document

Return the disposition value.

Usage

From source file:org.apache.tika.server.resource.TikaResource.java

public static String detectFilename(MultivaluedMap<String, String> httpHeaders) {

    String disposition = httpHeaders.getFirst("Content-Disposition");
    if (disposition != null) {
        try {//from   www  . ja va 2s  . c  o m
            ContentDisposition c = new ContentDisposition(disposition);

            // only support "attachment" dispositions
            if ("attachment".equals(c.getDisposition())) {
                String fn = c.getParameter("filename");
                if (fn != null) {
                    return fn;
                }
            }
        } catch (ParseException e) {
            // not a valid content-disposition field
            LOG.warn("Parse exception {} determining content disposition", e.getMessage(), e);
        }
    }

    // this really should not be used, since it's not an official field
    return httpHeaders.getFirst("File-Name");
}