download


Description:

[ Version ( since = "0.8.0" ) ]
public DownloadStream download (DocumentsService service, string export_format, Cancellable? cancellable = null) throws Error

Downloads and returns the document file represented by the DocumentsDocument .

If the document doesn't exist, null is returned, but no error is set in error.

export_format should be the file extension of the desired output format for the document, from the list accepted by Google Documents. For example: PDF, ODS or ODT.

If this is a DocumentsSpreadsheet, only the first grid, or sheet, in the spreadsheet will be downloaded for some export formats. To download a specific a specific grid, use get_download_uri with DownloadStream to download the grid manually. See the GData protocol specification for more information.

To get the content type of the downloaded file, get_content_type can be called on the returned DownloadStream. Calling get_content_length on the stream will not return a meaningful result, however, as the stream is encoded in chunks, rather than by content length.

In order to cancel the download, a Cancellable passed in to cancellable must be cancelled using cancel. Cancelling the individual InputStream operations on the DownloadStream will not cancel the entire download; merely the read or close operation in question. See the cancellable for more details.

If the given export_format is unrecognised or not supported for this document, NOT_FOUND will be returned.

If service isn't authenticated, a AUTHENTICATION_REQUIRED will be returned.

If there is an error getting the document, a PROTOCOL_ERROR error will be returned.

Parameters:

this

a DocumentsDocument

service

a DocumentsService

export_format

the format in which the document should be exported

cancellable

a Cancellable for the entire download stream, or null

Returns:

a DownloadStream to download the document with, or null; unref with unref