cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Mime type on uploaded file

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 15 Apr 2003 11:28:03 +0200 (CEST)

On Tue, 15 Apr 2003, Zvi Har'El wrote:

> I am using curl to upload HTML files to the w3c validation service at
> validator.w3.org/check, i.e.
>
> curl -F uploaded_file=@index.html http://validator.w3.org/check
>
> However, I get the response
>
> Sorry, I am unable to validate this document because its content type is
> text/plain, which is not currently supported by this service.
>
> Checking the origin of that using the --trace option of curl, I found out
> that curl adds this "text/plain" content type to the uploaded file. This is
> a part of the trace (up to the start of the html file):

[snip]

> If curl cannot identify my index.html file as an html file, from some reason, I
> suppose there should be some way to specify the correct mime-type of the
> uploaded file! I don't know if you wish to implement all the logic of the
> "file" command, but adding a curl option to specify this should be quicker.
> There might already be such an option, but somehow I didn't find it.

Weirdly enough, libcurl uses text/plain when it detects a .html suffix. I
can't see how this is anything but an error. I'll fix this.

Using text/plain as a default Content-Type: for this may be bad, I believe
some browsers use application/octet-stream instead.

You can set your own Content-Type with curl using a "type=" construct as in:

  curl -F "uploadthis=@filename;type=binary/chunk" [url]

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-04-15