|
From: Andy D. <an...@ma...> - 2005-03-04 18:20:15
|
Well, actually, here is what I was thinking. Say that I pull a resource from
a file or classpath (file: or classpath: or even just a relative path).
Then, sure, just figure out the mime type based on file extension when I call
"getMimeType" (or whatever) against the Resource. That at least saves me the
trouble of parsing the filename or calling into the activation framework.
BUT, if I pass in a URL to a resource where the mime type is handled
independently of the filename (such as a "http:" URL, where the server will
return a type header), then return the specific mime type that was returned
by the server. See URL.openConnection().getContentType(). A simple
algorithm could be:
getMimeType() {
return URL.openConnection().getContentType() if not null,
otherwise parse filename/use activation framework.
}
- Andy
On Friday 04 March 2005 07:01 am, Matt Sgarlata wrote:
> OK, I see what you're getting at now. The problem is, how do you want
> Spring to figure out the mime type if it's not based on file extension?
> By dynamically inspecting the contents of the file at runtime? I know
> that's possible because IE does it, but that seems like it would be a
> pain to implement. Is there some other approach you could take, like
> storing the mime type information external to the file itself?
>
> Matt
|