saveAs

Saves a file with the specified name and content. A server "echo" proxy might be required, depending on browser capabilities.

Parameters

options ObjectConfiguration options for the save operation.
options.dataURI StringThe file contents encoded as a Data URI.

Only base64-encoded Data URIs are supported.

options.fileName StringThe desired file name.
options.forceProxy Boolean (default: false)If set to true, the content will be forwarded to proxyURL even if the browser supports saving files locally.
options.proxyURL String (optional)The URL of the server side proxy which will stream the file to the end user.

A proxy will be used when the browser isn't capable of saving files locally. Such browsers are IE version 9 and lower and Safari.

The developer is responsible for implementing the server-side proxy.

When a proxy is used the kendo.saveAs() method includes any CSRF and anti-forgery tokens out of the box as long as they are present on the page. The logic internally uses the kendo.antiForgeryTokens() method and adds that to the request data as it posts to the proxy.

The proxy will receive a POST request with the following parameters in the request body:

  • contentType—This is the MIME type of the file.
  • base64—The base-64-encoded file content.
  • fileName—The file name as requested by the caller.
  • Any anti-forgery tokens if present on the page

The proxy should return the decoded file with set "Content-Disposition" header.

Example - Saving a text file

<script>
    kendo.saveAs({
        dataURI: "data:text/plain,Report title and text",
        fileName: "report.txt"
    });
</script>
options.proxyTarget String (default: "_self")

A name or keyword indicating where to display the document returned from the proxy.

If you want to display the document in a new window or iframe, the proxy should set the "Content-Disposition" header to inline; filename="<fileName.ext>".

In this article
Not finding the help you need? Improve this article