upload_document


Description:

[ Version ( since = "0.8.0" ) ]
public UploadStream upload_document (DocumentsDocument? document, string slug, string content_type, DocumentsFolder? folder, Cancellable? cancellable = null) throws Error

Uploads a document to Google Documents, using the properties from document and the document data written to the resulting UploadStream.

If the document data does not need to be provided at the moment, just the metadata, use insert_entry instead (e.g. in the case of creating a new, empty file to be edited at a later date).

This performs a non-resumable upload, unlike upload_document. This means that errors during transmission will cause the upload to fail, and the entire document will have to be re-uploaded. It is recommended that upload_document_resumable be used instead.

If document is null, only the document data will be uploaded. The new document entry will be named using slug , and will have default metadata.

The stream returned by this function should be written to using the standard OutputStream methods, asynchronously or synchronously. Once the stream is closed (using close), finish_upload should be called on it to parse and return the updated DocumentsDocument for the document. This must be done, as document isn't updated in-place.

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

Any upload errors will be thrown by the stream methods, and may come from the ServiceError domain.

Parameters:

this

an authenticated DocumentsService

document

the DocumentsDocument to insert, or null

slug

the filename to give to the uploaded document

content_type

the content type of the uploaded data

folder

the folder to which the document should be uploaded, or null

cancellable

a Cancellable for the entire upload stream, or null

Returns:

a UploadStream to write the document data to, or null; unref with unref