Overriding mime types

40 views
Skip to first unread message

Ian Phillips

unread,
Nov 21, 2014, 8:13:58 AM11/21/14
to spray...@googlegroups.com
I'd like to use the correct (i.e. official) mime type when serving up an XLS document, however if I try to register it using:

register(MediaType.custom(mainType = "application", subType = "vnd.ms-excel",
    compressible = true, binary = true, fileExtensions = Seq("xls")))

then I get this error:

Extension 'xls' clash: media-types 'application/excel' and 'application/vnd.ms-excel'

Is there a way I can override the default mime type or do I need to explicitly set the content type and disposition headers each time?

A related question: is it worth opening an issue/submitting a patch to spray-routing to change the default mime type for XLS files?

Johannes Rudolph

unread,
Dec 23, 2014, 7:15:40 AM12/23/14
to spray...@googlegroups.com
Hi Ian,

sorry, for letting this lying around for so long.

On Fri, Nov 21, 2014 at 2:13 PM, Ian Phillips <ian.ph...@gmail.com> wrote:
> Is there a way I can override the default mime type or do I need to
> explicitly set the content type and disposition headers each time?

As you have seen, you cannot register a custom mime type if the
extension was already taken. However, for the
`FileAndResourceDirectives` you can specify an implicit
`ContentTypeResolver` to guess an arbitrary content type from a file
name.

> A related question: is it worth opening an issue/submitting a patch to
> spray-routing to change the default mime type for XLS files?

Yes, that would definitely be helpful if you can back the proposal
with any kind reference document which acknowledges what the current
default mime type for xls should be.

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net
Reply all
Reply to author
Forward
0 new messages