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 throws.

export_format should be the file extension of the desired output format for the document, from the list accepted by Google Documents. For example: gdata_documents_presentation_pdf, gdata_documents_spreadsheet_ods or gdata_documents_text_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 <ulink type="http" url="https://developers.google.com/google-apps/documents-list/downloading_spreadsheetss">GData protocol specification< /ulink> 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, gdata_service_error_not_found will be returned.

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

If there is an error getting the document, a gdata_service_error_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