[Webtest] setFileField MIME type problem
Marc Guillemot
Marc Guillemot <mguillemot@yahoo.fr>
Fri, 19 Oct 2007 12:15:14 +0200
Roman Kažimír wrote:
> Hi!
>
> I'm trying to upload several kinds of documents into server using
> setFileField. But when I'm trying to upload MSWORD [*.DOC], wrong
> Content-Type is posted. Without Canoo engine, Content-Type:
> application/msword is posted, using Canoo Content-Type:
> application/octet-stream is posted. How to set additional mime types? Or
> how to solve upload ms-word docs?
>
> Regards, Roman
Hi Roman,
First your server shouldn't rely on it: the mime type set by the browser
for an uploaded file depends from the browser configuration therefore
you don't have any assurance that for instance a doc file will always
come as application/msword.
Then, exactly for this reason, I agree with you that setFileField should
allow to specify the content type value. Currently this value is
determined from the file content using
URLConnection.guessContentTypeFromStream
http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#guessContentTypeFromStream(java.io.InputStream)
but it should be configurable.
Can you please open an issue for it?
Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com