What contentType does c3DL support?


In the documentation it says:

Download the argument object as a file.
c3DL(content, [ contentType, [ filename ] ])

I’ve only found instances of “text/csv” and null. I’m specifically interested in downloading a Type to XML.


see the type ContentType, c3ShowType(ContentType)
In the docs of that type you will see the line:

Please refer to MediaType for the list of supported media types. For frequently used files such as .csv, .json, .xml, please use text/csv, application/json, and application/xml as their mimeType

c3ShowType(MediaType) gives a list of supported media types


c3DL takes three arguments:

  • content: the data to download
  • contentType: the MIME type
  • contentFilename: the downloaded file name

If contentType is not specified (normal case), c3DL tries to guess. Currently, if the content is an array or object, it choses “application/json”, otherwise “text/plain”.

If contentFilename is not specified, c3DL uses “download” with the appropriate extension.

You can be explicit about it by specifying all arguments. If you have a string with some HTML in it:

var doc = '<body><h1>Hello, world</h1></body>';
c3DL(doc, 'text/html', 'hello.html');


So in this case, I could only download a Type as json, and not XML, is that correct?


still gives me a json string


@JohnCoker? Any thoughts?


c3DL does not perform any conversion. The extra arguments are useful to specify a content type for strings or binary values where the system does not know it.